summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2014-10-08 17:14:48 +0200
committerCarlos Martín Nieto <cmn@dwim.me>2014-10-08 17:14:48 +0200
commit9b5d6cea4aba38a58233a93fde2d0ffd6945f171 (patch)
tree3e32cdc588b547501b3c73b520b7887a8cf7557d
parente7970576f1bcef1561813dbef339a31efabdc9b1 (diff)
downloadlibgit2-9b5d6cea4aba38a58233a93fde2d0ffd6945f171.tar.gz
revwalk: catch no-push and no-hide cases
If there have been no pushes, we can immediately return ITEROVER. If there have been no hides, we must not run the uninteresting pre-mark phase, as we do not want to hide anything and this would simply cause us to spend time loading objects.
-rw-r--r--src/revwalk.c24
-rw-r--r--src/revwalk.h4
2 files changed, 17 insertions, 11 deletions
diff --git a/src/revwalk.c b/src/revwalk.c
index a1d761f1b..1bf9fbe5c 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -142,6 +142,11 @@ static int push_commit(git_revwalk *walk, const git_oid *oid, int uninteresting,
if (commit == NULL)
return -1; /* error already reported by failed lookup */
+ if (uninteresting)
+ walk->did_hide = 1;
+ else
+ walk->did_push = 1;
+
commit->uninteresting = uninteresting;
list = walk->user_input;
if (git_commit_list_insert(commit, &list) == NULL) {
@@ -441,26 +446,24 @@ cleanup:
static int prepare_walk(git_revwalk *walk)
{
- int error, interesting = 0;
+ int error;
git_commit_list *list;
git_commit_list_node *next;
- if ((error = premark_uninteresting(walk)) < 0)
+ /* If there were no pushes, we know that the walk is already over */
+ if (!walk->did_push) {
+ giterr_clear();
+ return GIT_ITEROVER;
+ }
+
+ if (walk->did_hide && (error = premark_uninteresting(walk)) < 0)
return error;
for (list = walk->user_input; list; list = list->next) {
- interesting += !list->item->uninteresting;
if (process_commit(walk, list->item, list->item->uninteresting) < 0)
return -1;
}
- /*
- * If there were no pushes, we know that the walk is already over.
- */
- if (!interesting) {
- giterr_clear();
- return GIT_ITEROVER;
- }
if (walk->sorting & GIT_SORT_TOPOLOGICAL) {
unsigned short i;
@@ -619,6 +622,7 @@ void git_revwalk_reset(git_revwalk *walk)
git_commit_list_free(&walk->iterator_reverse);
git_commit_list_free(&walk->user_input);
walk->walking = 0;
+ walk->did_push = walk->did_hide = 0;
}
int git_revwalk_add_hide_cb(
diff --git a/src/revwalk.h b/src/revwalk.h
index 05a7a4223..72ddedc75 100644
--- a/src/revwalk.h
+++ b/src/revwalk.h
@@ -32,7 +32,9 @@ struct git_revwalk {
int (*enqueue)(git_revwalk *, git_commit_list_node *);
unsigned walking:1,
- first_parent: 1;
+ first_parent: 1,
+ did_hide: 1,
+ did_push: 1;
unsigned int sorting;
/* the pushes and hides */