summaryrefslogtreecommitdiff
path: root/src/revwalk.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2010-05-28 01:48:59 +0200
committerAndreas Ericsson <ae@op5.se>2010-06-02 10:32:07 +0200
commit6bb7aa1318f7f31a346c71ef81d2b33c6fd41600 (patch)
tree6fdccd49f442a7204399ca9b418f017322dbded8 /src/revwalk.c
parent0daa6cdcad92746551f78edfa93be0bc188d4f4a (diff)
downloadlibgit2-6bb7aa1318f7f31a346c71ef81d2b33c6fd41600.tar.gz
Added new error codes. Improved error handling.
Signed-off-by: Vicent Marti <tanoku@gmail.com> Signed-off-by: Andreas Ericsson <ae@op5.se>
Diffstat (limited to 'src/revwalk.c')
-rw-r--r--src/revwalk.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index 200a9469e..186a08f4b 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -62,17 +62,17 @@ void gitrp_sorting(git_revpool *pool, unsigned int sort_mode)
gitrp_reset(pool);
}
-void gitrp_push(git_revpool *pool, git_commit *commit)
+int gitrp_push(git_revpool *pool, git_commit *commit)
{
if (commit == NULL || commit->seen)
- return;
+ return GIT_ENOTFOUND;
if (commit->object.pool != pool || pool->walking)
- return;
+ return GIT_ERROR;
if (!commit->parsed) {
if (git_commit_parse_existing(commit) < 0)
- return;
+ return GIT_EOBJCORRUPTED;
}
// Sanity check: make sure that if the commit
@@ -81,36 +81,48 @@ void gitrp_push(git_revpool *pool, git_commit *commit)
if (commit->uninteresting)
git_commit__mark_uninteresting(commit);
- git_commit_list_push_back(&pool->roots, commit);
+ if (git_commit_list_push_back(&pool->roots, commit) < 0)
+ return GIT_ENOMEM;
+
+ return 0;
}
-void gitrp_hide(git_revpool *pool, git_commit *commit)
+int gitrp_hide(git_revpool *pool, git_commit *commit)
{
if (pool->walking)
- return;
+ return GIT_ERROR;
git_commit__mark_uninteresting(commit);
- gitrp_push(pool, commit);
+ return gitrp_push(pool, commit);
}
-void gitrp__enroot(git_revpool *pool, git_commit *commit)
+int gitrp__enroot(git_revpool *pool, git_commit *commit)
{
+ int error;
git_commit_node *parents;
if (commit->seen)
- return;
+ return 0;
- if (commit->parsed == 0)
- git_commit_parse_existing(commit);
+ if (commit->parsed == 0) {
+ if (git_commit_parse_existing(commit))
+ return GIT_EOBJCORRUPTED;
+ }
commit->seen = 1;
for (parents = commit->parents.head; parents != NULL; parents = parents->next) {
parents->commit->in_degree++;
- gitrp__enroot(pool, parents->commit);
+
+ error = gitrp__enroot(pool, parents->commit);
+ if (error < 0)
+ return error;
}
- git_commit_list_push_back(&pool->iterator, commit);
+ if (git_commit_list_push_back(&pool->iterator, commit))
+ return GIT_ENOMEM;
+
+ return 0;
}
void gitrp__prepare_walk(git_revpool *pool)