@matheusbsbs / matheus-bagliano / commits / e0b9c34f7e
Fork 0

t6007: Make sure we test --cherry-pick

Test 5 wants to test --cherry-pick but limits by pathspec in such a way that there are no commits on the left side of the range. Add a test without "--cherry-pick" which displays this, and add two more commits and another test which tests what we're after. This also shortens the last test. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Feb 18, 2011 at 13:34 UTC e0b9c34f7eec9d7943bbb8a3134f24e6e4e4ed3e
1 file changed +41 -8
t/t6007-rev-list-cherry-pick-file.sh
+41 -8
@@ -4,13 +4,14 @@ test_description='test git rev-list --cherry-pick -- file'
4
5 . ./test-lib.sh
6
7 -# A---B
7 +# A---B---D
8 # \
9 # \
10 -# C
10 +# C---E
11 #
12 # B changes a file foo.c, adding a line of text. C changes foo.c as
13 # well as bar.c, but the change in foo.c was identical to change B.
14 +# D and C change bar in the same way, E differently.
15
16 test_expect_success setup '
17 echo Hallo > foo &&
@@ -25,11 +26,21 @@ test_expect_success setup '
26 test_tick &&
27 git commit -m "C" &&
28 git tag C &&
29 + echo Dello > bar &&
30 + git add bar &&
31 + test_tick &&
32 + git commit -m "E" &&
33 + git tag E &&
34 git checkout master &&
35 git checkout branch foo &&
36 test_tick &&
37 git commit -m "B" &&
32 - git tag B
38 + git tag B &&
39 + echo Cello > bar &&
40 + git add bar &&
41 + test_tick &&
42 + git commit -m "D" &&
43 + git tag D
44 '
45
46 cat >expect <<EOF
@@ -53,8 +64,33 @@ test_expect_success '--cherry-pick foo comes up empty' '
64 test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
65 '
66
67 +cat >expect <<EOF
68 +>tags/C
69 +EOF
70 +
71 test_expect_success '--cherry-pick bar does not come up empty' '
57 - ! test -z "$(git rev-list --left-right --cherry-pick B...C -- bar)"
72 + git rev-list --left-right --cherry-pick B...C -- bar > actual &&
73 + git name-rev --stdin --name-only --refs="*tags/*" \
74 + < actual > actual.named &&
75 + test_cmp actual.named expect
76 +'
77 +
78 +test_expect_success 'bar does not come up empty' '
79 + git rev-list --left-right B...C -- bar > actual &&
80 + git name-rev --stdin --name-only --refs="*tags/*" \
81 + < actual > actual.named &&
82 + test_cmp actual.named expect
83 +'
84 +
85 +cat >expect <<EOF
86 +>tags/E
87 +EOF
88 +
89 +test_expect_success '--cherry-pick bar does not come up empty (II)' '
90 + git rev-list --left-right --cherry-pick D...E -- bar > actual &&
91 + git name-rev --stdin --name-only --refs="*tags/*" \
92 + < actual > actual.named &&
93 + test_cmp actual.named expect
94 '
95
96 test_expect_success '--cherry-pick with independent, but identical branches' '
@@ -75,11 +111,8 @@ cat >expect <<EOF
111 1 2
112 EOF
113
78 -# Insert an extra commit to break the symmetry
114 test_expect_success '--count --left-right' '
80 - git checkout branch &&
81 - test_commit D &&
82 - git rev-list --count --left-right B...D > actual &&
115 + git rev-list --count --left-right C...D > actual &&
116 test_cmp expect actual
117 '
118