diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-03-26 20:13:17 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-03-26 20:13:17 -0700 |
commit | bf0c5bbe2566d756d7468331161461ea9fec3b1f (patch) | |
tree | 3179922b7a98d866fcf86406ac62c5825cb37f63 /revision.c | |
parent | 8194fcaa1f0999064a170ed24d36be5432815dce (diff) | |
parent | 482ce70e14fdd5d03304a92f1740e6a9022e7958 (diff) | |
download | git-bf0c5bbe2566d756d7468331161461ea9fec3b1f.tar.gz |
Merge branch 'mg/rev-list-n-parents'
* mg/rev-list-n-parents:
tests: avoid nonportable {foo,bar} glob
rev-list --min-parents,--max-parents: doc, test and completion
revision.c: introduce --min-parents and --max-parents options
t6009: use test_commit() from test-lib.sh
Diffstat (limited to 'revision.c')
-rw-r--r-- | revision.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/revision.c b/revision.c index e96c281d1f..0f38364cf3 100644 --- a/revision.c +++ b/revision.c @@ -941,6 +941,7 @@ void init_revisions(struct rev_info *revs, const char *prefix) revs->min_age = -1; revs->skip_count = -1; revs->max_count = -1; + revs->max_parents = -1; revs->commit_format = CMIT_FMT_DEFAULT; @@ -1277,9 +1278,17 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg } else if (!strcmp(arg, "--remove-empty")) { revs->remove_empty_trees = 1; } else if (!strcmp(arg, "--merges")) { - revs->merges_only = 1; + revs->min_parents = 2; } else if (!strcmp(arg, "--no-merges")) { - revs->no_merges = 1; + revs->max_parents = 1; + } else if (!prefixcmp(arg, "--min-parents=")) { + revs->min_parents = atoi(arg+14); + } else if (!prefixcmp(arg, "--no-min-parents")) { + revs->min_parents = 0; + } else if (!prefixcmp(arg, "--max-parents=")) { + revs->max_parents = atoi(arg+14); + } else if (!prefixcmp(arg, "--no-max-parents")) { + revs->max_parents = -1; } else if (!strcmp(arg, "--boundary")) { revs->boundary = 1; } else if (!strcmp(arg, "--left-right")) { @@ -1298,7 +1307,7 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg die("--cherry is incompatible with --left-only"); revs->cherry_mark = 1; revs->right_only = 1; - revs->no_merges = 1; + revs->max_parents = 1; revs->limited = 1; } else if (!strcmp(arg, "--count")) { revs->count = 1; @@ -2029,10 +2038,15 @@ enum commit_action get_commit_action(struct rev_info *revs, struct commit *commi return commit_ignore; if (revs->min_age != -1 && (commit->date > revs->min_age)) return commit_ignore; - if (revs->no_merges && commit->parents && commit->parents->next) - return commit_ignore; - if (revs->merges_only && !(commit->parents && commit->parents->next)) - return commit_ignore; + if (revs->min_parents || (revs->max_parents >= 0)) { + int n = 0; + struct commit_list *p; + for (p = commit->parents; p; p = p->next) + n++; + if ((n < revs->min_parents) || + ((revs->max_parents >= 0) && (n > revs->max_parents))) + return commit_ignore; + } if (!commit_match(commit, revs)) return commit_ignore; if (revs->prune && revs->dense) { |