diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-09-08 02:52:26 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-09-09 22:31:14 +0400 |
commit | 15f7b9b8d9bdfb68ca52d582be40cf6112464e77 (patch) | |
tree | 5f2654223d4e34d04e3630c0ee95fc02a8d6db4e /src/revwalk.c | |
parent | ef6389ad504037e7a4311adbf14f1fa5a5aa4190 (diff) |
revwalk: allow simplifying by first-parent
When enabled, only the first parent of each commit will be queued,
enabling a simple way of using first-parent simplification.
Diffstat (limited to 'src/revwalk.c')
-rw-r--r-- | src/revwalk.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/revwalk.c b/src/revwalk.c index 1ff41bfb1..9e1e39ca4 100644 --- a/src/revwalk.c +++ b/src/revwalk.c @@ -99,10 +99,14 @@ static int process_commit(git_revwalk *walk, git_commit_list_node *commit, int h static int process_commit_parents(git_revwalk *walk, git_commit_list_node *commit) { - unsigned short i; + unsigned short i, max; int error = 0; - for (i = 0; i < commit->out_degree && !error; ++i) + max = commit->out_degree; + if (walk->first_parent && commit->out_degree) + max = 1; + + for (i = 0; i < max && !error; ++i) error = process_commit(walk, commit->parents[i], commit->uninteresting); return error; @@ -333,7 +337,7 @@ static int revwalk_next_unsorted(git_commit_list_node **object_out, git_revwalk static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk *walk) { git_commit_list_node *next; - unsigned short i; + unsigned short i, max; for (;;) { next = git_commit_list_pop(&walk->iterator_topo); @@ -347,7 +351,12 @@ static int revwalk_next_toposort(git_commit_list_node **object_out, git_revwalk continue; } - for (i = 0; i < next->out_degree; ++i) { + + max = next->out_degree; + if (walk->first_parent && next->out_degree) + max = 1; + + for (i = 0; i < max; ++i) { git_commit_list_node *parent = next->parents[i]; if (--parent->in_degree == 0 && parent->topo_delay) { @@ -505,6 +514,11 @@ void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode) } } +void git_revwalk_simplify_first_parent(git_revwalk *walk) +{ + walk->first_parent = 1; +} + int git_revwalk_next(git_oid *oid, git_revwalk *walk) { int error; |