Commit 8d453f16385c04abfba0211f1e7fb1621f26d609

lhchavez 2021-07-27T13:00:31

Swap the order of the `git_graph_reachable_from_any` params len, array -> array, len

diff --git a/include/git2/graph.h b/include/git2/graph.h
index cd4897f..712ae47 100644
--- a/include/git2/graph.h
+++ b/include/git2/graph.h
@@ -68,8 +68,8 @@ GIT_EXTERN(int) git_graph_descendant_of(
 GIT_EXTERN(int) git_graph_reachable_from_any(
 	git_repository *repo,
 	const git_oid *commit,
-	size_t length,
-	const git_oid descendant_array[]);
+	const git_oid descendant_array[],
+	size_t length);
 
 /** @} */
 GIT_END_DECL
diff --git a/src/graph.c b/src/graph.c
index 6efeb4a..35e914f 100644
--- a/src/graph.c
+++ b/src/graph.c
@@ -179,14 +179,14 @@ int git_graph_descendant_of(git_repository *repo, const git_oid *commit, const g
 	if (git_oid_equal(commit, ancestor))
 		return 0;
 
-	return git_graph_reachable_from_any(repo, ancestor, 1, commit);
+	return git_graph_reachable_from_any(repo, ancestor, commit, 1);
 }
 
 int git_graph_reachable_from_any(
 		git_repository *repo,
 		const git_oid *commit_id,
-		size_t length,
-		const git_oid descendant_array[])
+		const git_oid descendant_array[],
+		size_t length)
 {
 	git_revwalk *walk = NULL;
 	git_vector list;
diff --git a/tests/graph/reachable_from_any.c b/tests/graph/reachable_from_any.c
index 7dfd9dd..5c84164 100644
--- a/tests/graph/reachable_from_any.c
+++ b/tests/graph/reachable_from_any.c
@@ -45,11 +45,11 @@ void test_graph_reachable_from_any__returns_correct_result(void)
 
 	cl_assert_equal_i(
 			git_graph_reachable_from_any(
-					repo, git_object_id(branchH1), 1, git_object_id(branchA1)),
+					repo, git_object_id(branchH1), git_object_id(branchA1), 1),
 			0);
 	cl_assert_equal_i(
 			git_graph_reachable_from_any(
-					repo, git_object_id(branchH1), 1, git_object_id(branchA2)),
+					repo, git_object_id(branchH1), git_object_id(branchA2), 1),
 			0);
 
 	cl_git_pass(git_oid_cpy(&descendants[0], git_object_id(branchA1)));
@@ -60,10 +60,10 @@ void test_graph_reachable_from_any__returns_correct_result(void)
 	cl_git_pass(git_oid_cpy(&descendants[5], git_object_id(branchC2)));
 	cl_git_pass(git_oid_cpy(&descendants[6], git_object_id(branchH2)));
 	cl_assert_equal_i(
-			git_graph_reachable_from_any(repo, git_object_id(branchH2), 6, descendants),
+			git_graph_reachable_from_any(repo, git_object_id(branchH2), descendants, 6),
 			0);
 	cl_assert_equal_i(
-			git_graph_reachable_from_any(repo, git_object_id(branchH2), 7, descendants),
+			git_graph_reachable_from_any(repo, git_object_id(branchH2), descendants, 7),
 			1);
 
 	git_object_free(branchA1);
@@ -197,8 +197,8 @@ void test_graph_reachable_from_any__exhaustive(void)
 			actual_reachable = git_graph_reachable_from_any(
 					repo,
 					git_commit_id(parent_commit),
-					n_descendants,
-					descendants);
+					descendants,
+					n_descendants);
 			if (actual_reachable != expected_reachable) {
 				git_buf error_message_buf = GIT_BUF_INIT;
 				char parent_oidbuf[9] = {0}, child_oidbuf[9] = {0};