diff --git a/src/commit_list.c b/src/commit_list.c index c1a7b223f..734e1051f 100644 --- a/src/commit_list.c +++ b/src/commit_list.c @@ -127,7 +127,7 @@ static int commit_quick_parse(git_revwalk *walk, git_commit_list_node *commit, g if (git_oid_fromstr(&oid, (char *)buffer + strlen("parent ")) < 0) return -1; - commit->parents[i] = commit_lookup(walk, &oid); + commit->parents[i] = git_revwalk__commit_lookup(walk, &oid); if (commit->parents[i] == NULL) return -1; @@ -181,9 +181,13 @@ int git_commit_list_parse(git_revwalk *walk, git_commit_list_node *commit) if ((error = git_odb_read(&obj, walk->odb, &commit->oid)) < 0) return error; - assert(obj->raw.type == GIT_OBJ_COMMIT); - error = commit_quick_parse(walk, commit, &obj->raw); + if (obj->raw.type == GIT_OBJ_COMMIT) { + giterr_set(GITERR_INVALID, "Object is no commit object"); + error = -1; + } else + error = commit_quick_parse(walk, commit, &obj->raw); + git_odb_object_free(obj); return error; } diff --git a/src/graph.c b/src/graph.c index ff0a8464a..28026d4b4 100644 --- a/src/graph.c +++ b/src/graph.c @@ -58,7 +58,7 @@ int git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, if (git_revwalk_new(&walk, repo) < 0) return -1; - commit2 = commit_lookup(walk, two); + commit2 = git_revwalk__commit_lookup(walk, two); if (commit2 == NULL) goto on_error; @@ -68,7 +68,7 @@ int git_graph_ahead_behind(size_t *ahead, size_t *behind, git_repository *repo, list.length = 1; list.contents = contents; - commit1 = commit_lookup(walk, one); + commit1 = git_revwalk__commit_lookup(walk, one); if (commit1 == NULL) goto on_error; diff --git a/src/merge.c b/src/merge.c index 323b7b877..1386d0908 100644 --- a/src/merge.c +++ b/src/merge.c @@ -71,14 +71,14 @@ int git_merge_base_many(git_oid *out, git_repository *repo, const git_oid input_ goto cleanup; for (i = 1; i < length; i++) { - commit = commit_lookup(walk, &input_array[i]); + commit = git_revwalk__commit_lookup(walk, &input_array[i]); if (commit == NULL) goto cleanup; git_vector_insert(&list, commit); } - commit = commit_lookup(walk, &input_array[0]); + commit = git_revwalk__commit_lookup(walk, &input_array[0]); if (commit == NULL) goto cleanup; @@ -112,7 +112,7 @@ int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const if (git_revwalk_new(&walk, repo) < 0) return -1; - commit = commit_lookup(walk, two); + commit = git_revwalk__commit_lookup(walk, two); if (commit == NULL) goto on_error; @@ -122,7 +122,7 @@ int git_merge_base(git_oid *out, git_repository *repo, const git_oid *one, const list.length = 1; list.contents = contents; - commit = commit_lookup(walk, one); + commit = git_revwalk__commit_lookup(walk, one); if (commit == NULL) goto on_error; diff --git a/src/revwalk.c b/src/revwalk.c index bdbbdbd17..cad2f09bd 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -15,7 +15,8 @@ #include -git_commit_list_node *commit_lookup(git_revwalk *walk, const git_oid *oid) +git_commit_list_node *git_revwalk__commit_lookup( + git_revwalk *walk, const git_oid *oid) { git_commit_list_node *commit; khiter_t pos; @@ -101,7 +102,7 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting) return -1; } - commit = commit_lookup(walk, oid); + commit = git_revwalk__commit_lookup(walk, oid); if (commit == NULL) return -1; /* error already reported by failed lookup */ diff --git a/src/revwalk.h b/src/revwalk.h index 2d482cfcc..6146eaf25 100644 --- a/src/revwalk.h +++ b/src/revwalk.h @@ -39,6 +39,6 @@ struct git_revwalk { git_vector twos; }; -git_commit_list_node *commit_lookup(git_revwalk *walk, const git_oid *oid); +git_commit_list_node *git_revwalk__commit_lookup(git_revwalk *walk, const git_oid *oid); #endif diff --git a/tests-clar/revwalk/mergebase.c b/tests-clar/revwalk/mergebase.c index 2cd18601f..0eb6a9bdb 100644 --- a/tests-clar/revwalk/mergebase.c +++ b/tests-clar/revwalk/mergebase.c @@ -83,7 +83,7 @@ void test_revwalk_mergebase__merged_branch(void) cl_assert(behind == 0); } -void test_revwalk_meregebase__two_way_merge(void) +void test_revwalk_mergebase__two_way_merge(void) { git_oid one, two; size_t ahead, behind;