summaryrefslogtreecommitdiff
path: root/src/commit_list.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-11-29 17:02:27 -0800
committerRussell Belfer <rb@github.com>2012-11-29 17:02:27 -0800
commitd5e44d84983ba199a62ec67f823312584339fae3 (patch)
treec9c1cd5c6ef12dd4ccd40f274f17a3bf4d077e52 /src/commit_list.c
parentb994bfe3398d797ff8e8bb538eec41602d5e360a (diff)
downloadlibgit2-d5e44d84983ba199a62ec67f823312584339fae3.tar.gz
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.
Diffstat (limited to 'src/commit_list.c')
-rw-r--r--src/commit_list.c10
1 files changed, 7 insertions, 3 deletions
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;
}