diff options
author | Anurag Gupta <anugupta@microsoft.com> | 2014-03-31 15:15:32 -0700 |
---|---|---|
committer | Anurag Gupta <anugupta@microsoft.com> | 2014-03-31 15:15:32 -0700 |
commit | 3bc3d797611fccdf7a15cafafbb965b37fbb03f1 (patch) | |
tree | c3aa49509a5e99678a6d9f83e0b6221c7f2d4faf /src | |
parent | fad04120275925257a93312a3e05af64e9d17090 (diff) | |
download | libgit2-3bc3d797611fccdf7a15cafafbb965b37fbb03f1.tar.gz |
No need to find merge base.
Diffstat (limited to 'src')
-rw-r--r-- | src/revwalk.c | 52 | ||||
-rw-r--r-- | src/revwalk.h | 3 |
2 files changed, 18 insertions, 37 deletions
diff --git a/src/revwalk.c b/src/revwalk.c index f0109360b..7aedd1f44 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -39,8 +39,9 @@ git_commit_list_node *git_revwalk__commit_lookup( return commit; } -static int mark_uninteresting(git_commit_list_node *commit) +static int mark_uninteresting(git_revwalk *walk, git_commit_list_node *commit) { + int error; unsigned short i; git_array_t(git_commit_list_node *) pending = GIT_ARRAY_INIT; git_commit_list_node **tmp; @@ -53,12 +54,8 @@ static int mark_uninteresting(git_commit_list_node *commit) do { commit->uninteresting = 1; - /* This means we've reached a merge base, so there's no need to walk any more */ - if ((commit->flags & (RESULT | STALE)) == RESULT) { - tmp = git_array_pop(pending); - commit = tmp ? *tmp : NULL; - continue; - } + if ((error = git_commit_list_parse(walk, commit)) < 0) + return error; for (i = 0; i < commit->out_degree; ++i) if (!commit->parents[i]->uninteresting) { @@ -84,7 +81,7 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h if (!hide && walk->hide_cb) hide = walk->hide_cb(&commit->oid, walk->hide_cb_payload); - if (hide && mark_uninteresting(commit) < 0) + if (hide && mark_uninteresting(walk, commit) < 0) return -1; if (commit->seen) @@ -95,7 +92,10 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h if ((error = git_commit_list_parse(walk, commit)) < 0) return error; - return walk->enqueue(walk, commit); + if (!hide) + return walk->enqueue(walk, commit); + + return 0; } static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit) @@ -144,9 +144,6 @@ 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; - commit->uninteresting = uninteresting; if (walk->one == NULL && !uninteresting) { walk->one = commit; @@ -298,15 +295,14 @@ static int revwalk_next_timesort(git_commit_list_node **object_out, git_revwalk int error; git_commit_list_node *next; - while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) { - if ((error = process_commit_parents(walk, next)) < 0) - return error; - + while ((next = git_pqueue_pop(&walk->iterator_time)) != NULL) if (!next->uninteresting) { + if ((error = process_commit_parents(walk, next)) < 0) + return error; + *object_out = next; return 0; } - } giterr_clear(); return GIT_ITEROVER; @@ -317,15 +313,14 @@ static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk int error; git_commit_list_node *next; - while ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL) { - if ((error = process_commit_parents(walk, next)) < 0) - return error; - + while ((next = git_commit_list_pop(&walk->iterator_rand)) != NULL) if (!next->uninteresting) { + if ((error = process_commit_parents(walk, next)) < 0) + return error; + *object_out = next; return 0; } - } giterr_clear(); return GIT_ITEROVER; @@ -380,7 +375,6 @@ static int prepare_walk(git_revwalk *walk) int error; unsigned int i; git_commit_list_node *next, *two; - git_commit_list *bases = NULL; /* * If walk->one is NULL, there were no positive references, @@ -391,18 +385,6 @@ static int prepare_walk(git_revwalk *walk) return GIT_ITEROVER; } - /* - * If the user asked to hide commits, we need to figure out - * what the merge bases are so we can know when we can stop - * marking parents uninteresting. - */ - if (walk->did_hide) { - if (git_merge__bases_many(&bases, walk, walk->one, &walk->twos) < 0) - return -1; - - git_commit_list_free(&bases); - } - if (process_commit(walk, walk->one, walk->one->uninteresting) < 0) return -1; diff --git a/src/revwalk.h b/src/revwalk.h index a0654f3e5..d81f97c01 100644 --- a/src/revwalk.h +++ b/src/revwalk.h @@ -32,8 +32,7 @@ struct git_revwalk { int (*enqueue)(git_revwalk *, git_commit_list_node *); unsigned walking:1, - first_parent: 1, - did_hide: 1; + first_parent: 1; unsigned int sorting; /* merge base calculation */ |