summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael J Gruber <git@drmicha.warpmail.net>2011-03-23 09:38:51 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-03-23 17:20:24 (GMT)
commit6a6ebded7f2288d098f825f97cb2c210f0344497 (patch)
tree8186b099cd6f18596fdc0f95865f081cf8fbe8e6
parentad5aeeded3295589b2573b143f754762a56f8f82 (diff)
downloadgit-6a6ebded7f2288d098f825f97cb2c210f0344497.zip
git-6a6ebded7f2288d098f825f97cb2c210f0344497.tar.gz
git-6a6ebded7f2288d098f825f97cb2c210f0344497.tar.bz2
rev-list --min-parents,--max-parents: doc, test and completion
This also adds test for "--merges" and "--no-merges" which we did not have so far. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--Documentation/git-rev-list.txt4
-rw-r--r--Documentation/rev-list-options.txt19
-rwxr-xr-xcontrib/completion/git-completion.bash2
-rwxr-xr-xt/t6009-rev-list-parent.sh107
4 files changed, 129 insertions, 3 deletions
diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt
index 8a891ca..b2be202 100644
--- a/Documentation/git-rev-list.txt
+++ b/Documentation/git-rev-list.txt
@@ -16,6 +16,10 @@ SYNOPSIS
[ \--sparse ]
[ \--merges ]
[ \--no-merges ]
+ [ \--min-parents=<number> ]
+ [ \--no-min-parents ]
+ [ \--max-parents=<number> ]
+ [ \--no-max-parents ]
[ \--first-parent ]
[ \--remove-empty ]
[ \--full-history ]
diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt
index 95d209c..a02bb4b 100644
--- a/Documentation/rev-list-options.txt
+++ b/Documentation/rev-list-options.txt
@@ -226,11 +226,26 @@ endif::git-rev-list[]
--merges::
- Print only merge commits.
+ Print only merge commits. This is exactly the same as `--min-parents=2`.
--no-merges::
- Do not print commits with more than one parent.
+ Do not print commits with more than one parent. This is
+ exactly the same as `--max-parents=1`.
+
+--min-parents=<number>::
+--max-parents=<number>::
+--no-min-parents::
+--no-max-parents::
+
+ Show only commits which have at least (or at most) that many
+ commits. In particular, `--max-parents=1` is the same as `--no-merges`,
+ `--min-parents=2` is the same as `--merges`. `--max-parents=0`
+ gives all root commits and `--min-parents=3` all octopus merges.
++
+`--no-min-parents` and `--no-max-parents` reset these limits (to no limit)
+again. Equivalent forms are `--min-parents=0` (any commit has 0 or more
+parents) and `--max-parents=-1` (negative numbers denote no upper limit).
--first-parent::
Follow only the first parent commit upon seeing a merge
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 893b771..628970a 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -1572,6 +1572,8 @@ __git_log_common_options="
--max-count=
--max-age= --since= --after=
--min-age= --until= --before=
+ --min-parents= --max-parents=
+ --no-min-parents --no-max-parents
"
# Options that go well for log and gitk (not shortlog)
__git_log_gitk_options="
diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index 0f0e457..fc89d6d 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -1,9 +1,17 @@
#!/bin/sh
-test_description='properly cull all ancestors'
+test_description='ancestor culling and limiting by parent number'
. ./test-lib.sh
+check_revlist () {
+ rev_list_args="$1" &&
+ shift &&
+ git rev-parse "$@" >expect &&
+ git rev-list $rev_list_args --all >actual &&
+ test_cmp expect actual
+}
+
test_expect_success setup '
touch file &&
@@ -28,4 +36,101 @@ test_expect_success 'one is ancestor of others and should not be shown' '
'
+test_expect_success 'setup roots, merges and octopuses' '
+
+ git checkout --orphan newroot &&
+ test_commit five &&
+ git checkout -b sidebranch two &&
+ test_commit six &&
+ git checkout -b anotherbranch three &&
+ test_commit seven &&
+ git checkout -b yetanotherbranch four &&
+ test_commit eight &&
+ git checkout master &&
+ test_merge normalmerge newroot &&
+ test_tick &&
+ git merge -m tripus sidebranch anotherbranch &&
+ git tag tripus &&
+ git checkout -b tetrabranch normalmerge &&
+ test_tick &&
+ git merge -m tetrapus sidebranch anotherbranch yetanotherbranch &&
+ git tag tetrapus &&
+ git checkout master
+'
+
+test_expect_success 'rev-list roots' '
+
+ check_revlist "--max-parents=0" one five
+'
+
+test_expect_success 'rev-list no merges' '
+
+ check_revlist "--max-parents=1" one eight seven six five four three two &&
+ check_revlist "--no-merges" one eight seven six five four three two
+'
+
+test_expect_success 'rev-list no octopuses' '
+
+ check_revlist "--max-parents=2" one normalmerge eight seven six five four three two
+'
+
+test_expect_success 'rev-list no roots' '
+
+ check_revlist "--min-parents=1" tetrapus tripus normalmerge eight seven six four three two
+'
+
+test_expect_success 'rev-list merges' '
+
+ check_revlist "--min-parents=2" tetrapus tripus normalmerge &&
+ check_revlist "--merges" tetrapus tripus normalmerge
+'
+
+test_expect_success 'rev-list octopus' '
+
+ check_revlist "--min-parents=3" tetrapus tripus
+'
+
+test_expect_success 'rev-list ordinary commits' '
+
+ check_revlist "--min-parents=1 --max-parents=1" eight seven six four three two
+'
+
+test_expect_success 'rev-list --merges --no-merges yields empty set' '
+
+ check_revlist "--min-parents=2 --no-merges" &&
+ check_revlist "--merges --no-merges" &&
+ check_revlist "--no-merges --merges"
+'
+
+test_expect_success 'rev-list override and infinities' '
+
+ check_revlist "--min-parents=2 --max-parents=1 --max-parents=3" tripus normalmerge &&
+ check_revlist "--min-parents=1 --min-parents=2 --max-parents=7" tetrapus tripus normalmerge &&
+ check_revlist "--min-parents=2 --max-parents=8" tetrapus tripus normalmerge &&
+ check_revlist "--min-parents=2 --max-parents=-1" tetrapus tripus normalmerge &&
+ check_revlist "--min-parents=2 --no-max-parents" tetrapus tripus normalmerge &&
+ check_revlist "--max-parents=0 --min-parents=1 --no-min-parents" one five
+'
+
+test_expect_success 'set up dodecapus' '
+
+ for i in 1 2 3 4 5 6 7 8 9 10 11
+ do
+ git checkout -b root$i five || return
+ test_commit $i || return
+ done &&
+ git checkout master &&
+ test_tick &&
+ git merge -m dodecapus root{1,2,3,4,5,6,7,8,9,10,11} &&
+ git tag dodecapus
+'
+
+test_expect_success 'test with dodecapus' '
+
+ check_revlist "--min-parents=4" dodecapus tetrapus &&
+ check_revlist "--min-parents=8" dodecapus &&
+ check_revlist "--min-parents=12" dodecapus &&
+ check_revlist "--min-parents=13" &&
+ check_revlist "--min-parents=4 --max-parents=11" tetrapus
+'
test_done