Commit 9cd423583fc8ccb7402b2fb65478cc532d011abc

Russell Belfer 2012-11-20T16:57:16

API updates for submodule.h

diff --git a/include/git2/submodule.h b/include/git2/submodule.h
index b00fad2..90e45ce 100644
--- a/include/git2/submodule.h
+++ b/include/git2/submodule.h
@@ -318,7 +318,7 @@ GIT_EXTERN(int) git_submodule_set_url(git_submodule *submodule, const char *url)
  * @param submodule Pointer to submodule object
  * @return Pointer to git_oid or NULL if submodule is not in index.
  */
-GIT_EXTERN(const git_oid *) git_submodule_index_oid(git_submodule *submodule);
+GIT_EXTERN(const git_oid *) git_submodule_index_id(git_submodule *submodule);
 
 /**
  * Get the OID for the submodule in the current HEAD tree.
@@ -326,7 +326,7 @@ GIT_EXTERN(const git_oid *) git_submodule_index_oid(git_submodule *submodule);
  * @param submodule Pointer to submodule object
  * @return Pointer to git_oid or NULL if submodule is not in the HEAD.
  */
-GIT_EXTERN(const git_oid *) git_submodule_head_oid(git_submodule *submodule);
+GIT_EXTERN(const git_oid *) git_submodule_head_id(git_submodule *submodule);
 
 /**
  * Get the OID for the submodule in the current working directory.
@@ -339,7 +339,7 @@ GIT_EXTERN(const git_oid *) git_submodule_head_oid(git_submodule *submodule);
  * @param submodule Pointer to submodule object
  * @return Pointer to git_oid or NULL if submodule is not checked out.
  */
-GIT_EXTERN(const git_oid *) git_submodule_wd_oid(git_submodule *submodule);
+GIT_EXTERN(const git_oid *) git_submodule_wd_id(git_submodule *submodule);
 
 /**
  * Get the ignore rule for the submodule.
diff --git a/src/diff.c b/src/diff.c
index d6f5bd4..86f76f9 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -363,7 +363,7 @@ int git_diff__oid_for_file(
 		const git_oid *sm_oid;
 
 		if (!git_submodule_lookup(&sm, repo, path) &&
-			(sm_oid = git_submodule_wd_oid(sm)) != NULL)
+			(sm_oid = git_submodule_wd_id(sm)) != NULL)
 			git_oid_cpy(oid, sm_oid);
 		else {
 			/* if submodule lookup failed probably just in an intermediate
@@ -496,7 +496,7 @@ static int maybe_modified(
 
 				/* grab OID while we are here */
 				if (git_oid_iszero(&nitem->oid)) {
-					const git_oid *sm_oid = git_submodule_wd_oid(sub);
+					const git_oid *sm_oid = git_submodule_wd_id(sub);
 					if (sm_oid != NULL) {
 						git_oid_cpy(&noid, sm_oid);
 						use_noid = &noid;
diff --git a/src/diff_output.c b/src/diff_output.c
index 7873f06..804325e 100644
--- a/src/diff_output.c
+++ b/src/diff_output.c
@@ -287,8 +287,8 @@ static int get_workdir_sm_content(
 	if ((file->flags & GIT_DIFF_FILE_VALID_OID) == 0) {
 		const git_oid* sm_head;
 
-		if ((sm_head = git_submodule_wd_oid(sm)) != NULL ||
-			(sm_head = git_submodule_head_oid(sm)) != NULL)
+		if ((sm_head = git_submodule_wd_id(sm)) != NULL ||
+			(sm_head = git_submodule_head_id(sm)) != NULL)
 		{
 			git_oid_cpy(&file->oid, sm_head);
 			file->flags |= GIT_DIFF_FILE_VALID_OID;
diff --git a/src/submodule.c b/src/submodule.c
index 994ce31..bc38f1f 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -513,7 +513,7 @@ int git_submodule_set_url(git_submodule *submodule, const char *url)
 	return 0;
 }
 
-const git_oid *git_submodule_index_oid(git_submodule *submodule)
+const git_oid *git_submodule_index_id(git_submodule *submodule)
 {
 	assert(submodule);
 
@@ -523,7 +523,7 @@ const git_oid *git_submodule_index_oid(git_submodule *submodule)
 		return NULL;
 }
 
-const git_oid *git_submodule_head_oid(git_submodule *submodule)
+const git_oid *git_submodule_head_id(git_submodule *submodule)
 {
 	assert(submodule);
 
@@ -533,7 +533,7 @@ const git_oid *git_submodule_head_oid(git_submodule *submodule)
 		return NULL;
 }
 
-const git_oid *git_submodule_wd_oid(git_submodule *submodule)
+const git_oid *git_submodule_wd_id(git_submodule *submodule)
 {
 	assert(submodule);
 
@@ -1389,8 +1389,8 @@ cleanup:
 
 static int submodule_index_status(unsigned int *status, git_submodule *sm)
 {
-	const git_oid *head_oid  = git_submodule_head_oid(sm);
-	const git_oid *index_oid = git_submodule_index_oid(sm);
+	const git_oid *head_oid  = git_submodule_head_id(sm);
+	const git_oid *index_oid = git_submodule_index_id(sm);
 
 	if (!head_oid) {
 		if (index_oid)
@@ -1410,7 +1410,7 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
 	const git_oid *wd_oid, *index_oid;
 	git_repository *sm_repo = NULL;
 
-	/* open repo now if we need it (so wd_oid() call won't reopen) */
+	/* open repo now if we need it (so wd_id() call won't reopen) */
 	if ((sm->ignore == GIT_SUBMODULE_IGNORE_NONE ||
 		 sm->ignore == GIT_SUBMODULE_IGNORE_UNTRACKED) &&
 		(sm->flags & GIT_SUBMODULE_STATUS_IN_WD) != 0)
@@ -1419,8 +1419,8 @@ static int submodule_wd_status(unsigned int *status, git_submodule *sm)
 			return error;
 	}
 
-	index_oid = git_submodule_index_oid(sm);
-	wd_oid    = git_submodule_wd_oid(sm);
+	index_oid = git_submodule_index_id(sm);
+	wd_oid    = git_submodule_wd_id(sm);
 
 	if (!index_oid) {
 		if (wd_oid)
diff --git a/tests-clar/submodule/lookup.c b/tests-clar/submodule/lookup.c
index 94eb19b..868b51e 100644
--- a/tests-clar/submodule/lookup.c
+++ b/tests-clar/submodule/lookup.c
@@ -62,9 +62,9 @@ void test_submodule_lookup__accessors(void)
 	cl_assert(git__suffixcmp(git_submodule_path(sm), "sm_unchanged") == 0);
 	cl_assert(git__suffixcmp(git_submodule_url(sm), "/submod2_target") == 0);
 
-	cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
-	cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0);
-	cl_assert(git_oid_streq(git_submodule_wd_oid(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
 
 	cl_assert(git_submodule_ignore(sm) == GIT_SUBMODULE_IGNORE_NONE);
 	cl_assert(git_submodule_update(sm) == GIT_SUBMODULE_UPDATE_CHECKOUT);
@@ -72,24 +72,24 @@ void test_submodule_lookup__accessors(void)
 	cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_changed_head"));
 	cl_assert_equal_s("sm_changed_head", git_submodule_name(sm));
 
-	cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
-	cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0);
-	cl_assert(git_oid_streq(git_submodule_wd_oid(sm),
+	cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_wd_id(sm),
 		"3d9386c507f6b093471a3e324085657a3c2b4247") == 0);
 
 	cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_added_and_uncommited"));
 	cl_assert_equal_s("sm_added_and_uncommited", git_submodule_name(sm));
 
-	cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
-	cl_assert(git_submodule_head_oid(sm) == NULL);
-	cl_assert(git_oid_streq(git_submodule_wd_oid(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+	cl_assert(git_submodule_head_id(sm) == NULL);
+	cl_assert(git_oid_streq(git_submodule_wd_id(sm), oid) == 0);
 
 	cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_missing_commits"));
 	cl_assert_equal_s("sm_missing_commits", git_submodule_name(sm));
 
-	cl_assert(git_oid_streq(git_submodule_index_oid(sm), oid) == 0);
-	cl_assert(git_oid_streq(git_submodule_head_oid(sm), oid) == 0);
-	cl_assert(git_oid_streq(git_submodule_wd_oid(sm),
+	cl_assert(git_oid_streq(git_submodule_index_id(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_head_id(sm), oid) == 0);
+	cl_assert(git_oid_streq(git_submodule_wd_id(sm),
 		"5e4963595a9774b90524d35a807169049de8ccad") == 0);
 }