Code

t6007: Make sure we test --cherry-pick
[git.git] / t / t6007-rev-list-cherry-pick-file.sh
1 #!/bin/sh
3 test_description='test git rev-list --cherry-pick -- file'
5 . ./test-lib.sh
7 # A---B---D
8 #  \
9 #   \
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.
16 test_expect_success setup '
17         echo Hallo > foo &&
18         git add foo &&
19         test_tick &&
20         git commit -m "A" &&
21         git tag A &&
22         git checkout -b branch &&
23         echo Bello > foo &&
24         echo Cello > bar &&
25         git add foo bar &&
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" &&
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 '
46 cat >expect <<EOF
47 <tags/B
48 >tags/C
49 EOF
51 test_expect_success '--left-right' '
52         git rev-list --left-right B...C > actual &&
53         git name-rev --stdin --name-only --refs="*tags/*" \
54                 < actual > actual.named &&
55         test_cmp actual.named expect
56 '
58 test_expect_success '--count' '
59         git rev-list --count B...C > actual &&
60         test "$(cat actual)" = 2
61 '
63 test_expect_success '--cherry-pick foo comes up empty' '
64         test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)"
65 '
67 cat >expect <<EOF
68 >tags/C
69 EOF
71 test_expect_success '--cherry-pick bar does not come up empty' '
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 '
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 '
85 cat >expect <<EOF
86 >tags/E
87 EOF
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 '
96 test_expect_success '--cherry-pick with independent, but identical branches' '
97         git symbolic-ref HEAD refs/heads/independent &&
98         rm .git/index &&
99         echo Hallo > foo &&
100         git add foo &&
101         test_tick &&
102         git commit -m "independent" &&
103         echo Bello > foo &&
104         test_tick &&
105         git commit -m "independent, too" foo &&
106         test -z "$(git rev-list --left-right --cherry-pick \
107                 HEAD...master -- foo)"
110 cat >expect <<EOF
111 1       2
112 EOF
114 test_expect_success '--count --left-right' '
115         git rev-list --count --left-right C...D > actual &&
116         test_cmp expect actual
119 test_done