Commit de141d4b by Vicent Marti Committed by Andreas Ericsson

Improved error handling on auxilirary functions.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
Signed-off-by: Andreas Ericsson <ae@op5.se>
parent c2550609
......@@ -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)
......
......@@ -74,14 +74,14 @@ int git_revpool_table_insert(git_revpool_table *table, git_revpool_object *objec
unsigned int index, hash;
if (table == NULL)
return -1;
return GIT_ERROR;
if (table->count + 1 > table->max_count)
git_revpool_table_resize(table);
node = git__malloc(sizeof(git_revpool_node));
if (node == NULL)
return -1;
return GIT_ENOMEM;
hash = git_revpool_table__hash(&object->id);
index = (hash & table->size_mask);
......
......@@ -71,8 +71,9 @@ int gitrp_push(git_revpool *pool, git_commit *commit)
return GIT_ERROR;
if (!commit->parsed) {
if (git_commit_parse_existing(commit) < 0)
return GIT_EOBJCORRUPTED;
int error = git_commit_parse_existing(commit);
if (error < 0)
return error;
}
// Sanity check: make sure that if the commit
......@@ -105,8 +106,9 @@ int gitrp__enroot(git_revpool *pool, git_commit *commit)
return 0;
if (commit->parsed == 0) {
if (git_commit_parse_existing(commit))
return GIT_EOBJCORRUPTED;
error = git_commit_parse_existing(commit);
if (error < 0)
return error;
}
commit->seen = 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment