diff options
author | Thomas Rast <trast@student.ethz.ch> | 2010-06-10 13:47:23 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-06-12 09:39:06 -0700 |
commit | f69c501832ecd6880602c55565508e70c3a013d5 (patch) | |
tree | 0249f7780dd2aac4023e4f44c7670188c7778650 /t | |
parent | 3499cb1ae7b97ce8f67879156e2014e31dd985b6 (diff) | |
download | git-f69c501832ecd6880602c55565508e70c3a013d5.tar.gz git-f69c501832ecd6880602c55565508e70c3a013d5.tar.xz |
rev-list: introduce --count option
Add a --count option that, instead of actually listing the commits,
merely counts them.
This is mostly geared towards script use, and to this end it acts
specially when used with --left-right: it outputs the left and right
counts separately. Previously, scripts would have to run a shell loop
or small inline script over to achieve the same. (Without
--left-right, a simple |wc -l does the job.)
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t6007-rev-list-cherry-pick-file.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t6007-rev-list-cherry-pick-file.sh b/t/t6007-rev-list-cherry-pick-file.sh index 4b8611ce2..b565638e9 100755 --- a/t/t6007-rev-list-cherry-pick-file.sh +++ b/t/t6007-rev-list-cherry-pick-file.sh @@ -32,6 +32,23 @@ test_expect_success setup ' git tag B ' +cat >expect <<EOF +<tags/B +>tags/C +EOF + +test_expect_success '--left-right' ' + git rev-list --left-right B...C > actual && + git name-rev --stdin --name-only --refs="*tags/*" \ + < actual > actual.named && + test_cmp actual.named expect +' + +test_expect_success '--count' ' + git rev-list --count B...C > actual && + test "$(cat actual)" = 2 +' + test_expect_success '--cherry-pick foo comes up empty' ' test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)" ' @@ -54,4 +71,16 @@ test_expect_success '--cherry-pick with independent, but identical branches' ' HEAD...master -- foo)" ' +cat >expect <<EOF +1 2 +EOF + +# Insert an extra commit to break the symmetry +test_expect_success '--count --left-right' ' + git checkout branch && + test_commit D && + git rev-list --count --left-right B...D > actual && + test_cmp expect actual +' + test_done |