Commit 07fb67f90e79ecf35672008fed262a7db41d9790

Carlos Martín Nieto 2013-09-22T05:55:39

merge: reverse array and length parameter order Make it pair up with the one for commits. This fixes #1691.

diff --git a/include/git2/merge.h b/include/git2/merge.h
index 3f21fb4..62fd7d7 100644
--- a/include/git2/merge.h
+++ b/include/git2/merge.h
@@ -85,15 +85,15 @@ GIT_EXTERN(int) git_merge_base(
  *
  * @param out the OID of a merge base considering all the commits
  * @param repo the repository where the commits exist
- * @param input_array oids of the commits
  * @param length The number of commits in the provided `input_array`
+ * @param input_array oids of the commits
  * @return Zero on success; GIT_ENOTFOUND or -1 on failure.
  */
 GIT_EXTERN(int) git_merge_base_many(
 	git_oid *out,
 	git_repository *repo,
-	const git_oid input_array[],
-	size_t length);
+	size_t length,
+	const git_oid input_array[]);
 
 /**
  * Creates a `git_merge_head` from the given reference
diff --git a/src/merge.c b/src/merge.c
index 2e94ce1..b07e8c5 100644
--- a/src/merge.c
+++ b/src/merge.c
@@ -58,7 +58,7 @@ struct merge_diff_df_data {
 
 /* Merge base computation */
 
-int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_array[], size_t length)
+int git_merge_base_many(git_oid *out, git_repository *repo, size_t length, const git_oid input_array[])
 {
 	git_revwalk *walk;
 	git_vector list;
diff --git a/tests-clar/revwalk/mergebase.c b/tests-clar/revwalk/mergebase.c
index a2dbbc7..2d01647 100644
--- a/tests-clar/revwalk/mergebase.c
+++ b/tests-clar/revwalk/mergebase.c
@@ -172,9 +172,9 @@ static void assert_mergebase_many(const char *expected_sha, int count, ...)
 	va_end(ap);
 
 	if (expected_sha == NULL)
-		cl_assert_equal_i(GIT_ENOTFOUND, git_merge_base_many(&oid, _repo, oids, count));
+		cl_assert_equal_i(GIT_ENOTFOUND, git_merge_base_many(&oid, _repo, count, oids));
 	else {
-		cl_git_pass(git_merge_base_many(&oid, _repo, oids, count));
+		cl_git_pass(git_merge_base_many(&oid, _repo, count, oids));
 		cl_git_pass(git_oid_fromstr(&expected, expected_sha));
 
 		cl_assert(git_oid_cmp(&expected, &oid) == 0);