Skip to content

Commit

Permalink
rev-list: documentation and test for --left/right-only
Browse files Browse the repository at this point in the history
Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael J Gruber authored and Junio C Hamano committed Feb 22, 2011
1 parent e0b9c34 commit 59c8afd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Documentation/git-rev-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ SYNOPSIS
[ \--parents ]
[ \--timestamp ]
[ \--left-right ]
[ \--left-only ]
[ \--right-only ]
[ \--cherry-pick ]
[ \--encoding[=<encoding>] ]
[ \--(author|committer|grep)=<pattern> ]
Expand Down
13 changes: 13 additions & 0 deletions Documentation/rev-list-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,19 @@ from the other branch (for example, "3rd on b" may be cherry-picked
from branch A). With this option, such pairs of commits are
excluded from the output.

--left-only::
--right-only::

List only commits on the respective side of a symmetric range,
i.e. only those which would be marked `<` resp. `>` by
`--left-right`.
+
For example, `--cherry-pick --right-only A...B` omits those
commits from `B` which are in `A` or are patch-equivalent to a commit in
`A`. In other words, this lists the `{plus}` commits from `git cherry A B`.
More precisely, `--cherry-pick --right-only --no-merges` gives the exact
list.

-g::
--walk-reflogs::

Expand Down
32 changes: 28 additions & 4 deletions t/t6007-rev-list-cherry-pick-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ test_description='test git rev-list --cherry-pick -- file'

. ./test-lib.sh

# A---B---D
# A---B---D---F
# \
# \
# C---E
#
# B changes a file foo.c, adding a line of text. C changes foo.c as
# well as bar.c, but the change in foo.c was identical to change B.
# D and C change bar in the same way, E differently.
# D and C change bar in the same way, E and F differently.

test_expect_success setup '
echo Hallo > foo &&
Expand Down Expand Up @@ -40,7 +40,12 @@ test_expect_success setup '
git add bar &&
test_tick &&
git commit -m "D" &&
git tag D
git tag D &&
echo Nello > bar &&
git add bar &&
test_tick &&
git commit -m "F" &&
git tag F
'

cat >expect <<EOF
Expand Down Expand Up @@ -83,11 +88,30 @@ test_expect_success 'bar does not come up empty' '
'

cat >expect <<EOF
<tags/F
>tags/E
EOF

test_expect_success '--cherry-pick bar does not come up empty (II)' '
git rev-list --left-right --cherry-pick D...E -- bar > actual &&
git rev-list --left-right --cherry-pick F...E -- bar > actual &&
git name-rev --stdin --name-only --refs="*tags/*" \
< actual > actual.named &&
test_cmp actual.named expect
'

cat >expect <<EOF
tags/E
EOF

test_expect_success '--cherry-pick --right-only' '
git rev-list --cherry-pick --right-only F...E -- bar > actual &&
git name-rev --stdin --name-only --refs="*tags/*" \
< actual > actual.named &&
test_cmp actual.named expect
'

test_expect_success '--cherry-pick --left-only' '
git rev-list --cherry-pick --left-only E...F -- bar > actual &&
git name-rev --stdin --name-only --refs="*tags/*" \
< actual > actual.named &&
test_cmp actual.named expect
Expand Down

0 comments on commit 59c8afd

Please sign in to comment.