diff options
author | Vicent Marti <tanoku@gmail.com> | 2010-05-28 02:02:02 +0200 |
---|---|---|
committer | Andreas Ericsson <ae@op5.se> | 2010-06-02 10:32:07 +0200 |
commit | de141d4bb983dad861835e181e7ecd5692a58aba (patch) | |
tree | 40e1af83bd6b13b718c52673d2ad68edf54b6d6f /src/commit.c | |
parent | c2550609e37e0778814d328c47eb84a7ede6931f (diff) | |
download | libgit2-de141d4bb983dad861835e181e7ecd5692a58aba.tar.gz |
Improved error handling on auxilirary functions.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'src/commit.c')
-rw-r--r-- | src/commit.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/commit.c b/src/commit.c index 46c7d0de..ca528133 100644 --- a/src/commit.c +++ b/src/commit.c @@ -75,27 +75,27 @@ error_cleanup: int git_commit_parse_existing(git_commit *commit) { + int error = 0; git_obj commit_obj; if (commit->parsed) return 0; - if (git_odb_read(&commit_obj, commit->object.pool->db, &commit->object.id) < 0) - return GIT_ENOTFOUND; + error = git_odb_read(&commit_obj, commit->object.pool->db, &commit->object.id); + if (error < 0) + return error; if (commit_obj.type != GIT_OBJ_COMMIT) - goto error_cleanup; - - if (git_commit__parse_buffer(commit, commit_obj.data, commit_obj.len) < 0) - goto error_cleanup; - - git_obj_close(&commit_obj); + { + error = GIT_EOBJTYPE; + goto cleanup; + } - return 0; + error = git_commit__parse_buffer(commit, commit_obj.data, commit_obj.len); -error_cleanup: +cleanup: git_obj_close(&commit_obj); - return -1; + return error; } git_commit *git_commit_lookup(git_revpool *pool, const git_oid *id) @@ -205,7 +205,8 @@ int git_commit__parse_buffer(git_commit *commit, void *data, size_t len) if (commit->uninteresting) parent->uninteresting = 1; - git_commit_list_push_back(&commit->parents, parent); + if (git_commit_list_push_back(&commit->parents, parent)) + return GIT_ENOMEM; } if (git_commit__parse_time(&commit->commit_time, buffer, buffer_end) < 0) |