diff options
| author | Russell Belfer <rb@github.com> | 2013-09-10 16:55:58 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-09-10 16:55:58 -0700 |
| commit | 6c38e60a00ad9133b98f6c6b4e73054226c1f88a (patch) | |
| tree | 880a99e5c8fbad758805b6e39578881005221004 /src | |
| parent | 68642bce4b5ec895b25f48f402e8537b069f1924 (diff) | |
| parent | 15f7b9b8d9bdfb68ca52d582be40cf6112464e77 (diff) | |
| download | libgit2-6c38e60a00ad9133b98f6c6b4e73054226c1f88a.tar.gz | |
Merge pull request #1838 from libgit2/cmn/first-parent
revwalk: allow simplifying by first-parent
Diffstat (limited to 'src')
| -rw-r--r-- | src/revwalk.c | 22 | ||||
| -rw-r--r-- | src/revwalk.h | 3 |
2 files changed, 20 insertions, 5 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; diff --git a/src/revwalk.h b/src/revwalk.h index 22696dfcd..8c821d098 100644 --- a/src/revwalk.h +++ b/src/revwalk.h @@ -31,7 +31,8 @@ struct git_revwalk { int (*get_next)(git_commit_list_node **, git_revwalk *); int (*enqueue)(git_revwalk *, git_commit_list_node *); - unsigned walking:1; + unsigned walking:1, + first_parent: 1; unsigned int sorting; /* merge base calculation */ |
