mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-11 22:07:38 +00:00
Fix function name and add real error check
`revwalk.h:commit_lookup()` -> `git_revwalk__commit_lookup()` and make `git_commit_list_parse()` do real error checking that the item in the list is an actual commit object. Also fixed an apparent typo in a test name.
This commit is contained in:
parent
b994bfe339
commit
d5e44d8498
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
|
||||
#include <regex.h>
|
||||
|
||||
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 */
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user