]>
Commit | Line | Data |
---|---|---|
36d56de6 JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='test git rev-list --cherry-pick -- file' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
59c8afdf | 7 | # A---B---D---F |
36d56de6 JS |
8 | # \ |
9 | # \ | |
e0b9c34f | 10 | # C---E |
36d56de6 JS |
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. | |
59c8afdf | 14 | # D and C change bar in the same way, E and F differently. |
36d56de6 JS |
15 | |
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 && | |
e0b9c34f MG |
29 | echo Dello > bar && |
30 | git add bar && | |
31 | test_tick && | |
32 | git commit -m "E" && | |
33 | git tag E && | |
36d56de6 JS |
34 | git checkout master && |
35 | git checkout branch foo && | |
36 | test_tick && | |
37 | git commit -m "B" && | |
e0b9c34f MG |
38 | git tag B && |
39 | echo Cello > bar && | |
40 | git add bar && | |
41 | test_tick && | |
42 | git commit -m "D" && | |
59c8afdf MG |
43 | git tag D && |
44 | echo Nello > bar && | |
45 | git add bar && | |
46 | test_tick && | |
47 | git commit -m "F" && | |
48 | git tag F | |
36d56de6 JS |
49 | ' |
50 | ||
f69c5018 TR |
51 | cat >expect <<EOF |
52 | <tags/B | |
53 | >tags/C | |
54 | EOF | |
55 | ||
56 | test_expect_success '--left-right' ' | |
57 | git rev-list --left-right B...C > actual && | |
58 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
59 | < actual > actual.named && | |
60 | test_cmp actual.named expect | |
61 | ' | |
62 | ||
63 | test_expect_success '--count' ' | |
64 | git rev-list --count B...C > actual && | |
65 | test "$(cat actual)" = 2 | |
66 | ' | |
67 | ||
36d56de6 JS |
68 | test_expect_success '--cherry-pick foo comes up empty' ' |
69 | test -z "$(git rev-list --left-right --cherry-pick B...C -- foo)" | |
70 | ' | |
71 | ||
e0b9c34f MG |
72 | cat >expect <<EOF |
73 | >tags/C | |
74 | EOF | |
75 | ||
36d56de6 | 76 | test_expect_success '--cherry-pick bar does not come up empty' ' |
e0b9c34f MG |
77 | git rev-list --left-right --cherry-pick B...C -- bar > actual && |
78 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
79 | < actual > actual.named && | |
80 | test_cmp actual.named expect | |
81 | ' | |
82 | ||
83 | test_expect_success 'bar does not come up empty' ' | |
84 | git rev-list --left-right B...C -- bar > actual && | |
85 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
86 | < actual > actual.named && | |
87 | test_cmp actual.named expect | |
88 | ' | |
89 | ||
90 | cat >expect <<EOF | |
59c8afdf | 91 | <tags/F |
e0b9c34f MG |
92 | >tags/E |
93 | EOF | |
94 | ||
95 | test_expect_success '--cherry-pick bar does not come up empty (II)' ' | |
59c8afdf MG |
96 | git rev-list --left-right --cherry-pick F...E -- bar > actual && |
97 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
98 | < actual > actual.named && | |
99 | test_cmp actual.named expect | |
100 | ' | |
101 | ||
102 | cat >expect <<EOF | |
cb56e309 MG |
103 | +tags/F |
104 | =tags/D | |
105 | +tags/E | |
106 | =tags/C | |
107 | EOF | |
108 | ||
109 | test_expect_success '--cherry-mark' ' | |
110 | git rev-list --cherry-mark F...E -- bar > actual && | |
111 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
112 | < actual > actual.named && | |
113 | test_cmp actual.named expect | |
114 | ' | |
115 | ||
116 | cat >expect <<EOF | |
117 | <tags/F | |
118 | =tags/D | |
119 | >tags/E | |
120 | =tags/C | |
121 | EOF | |
122 | ||
123 | test_expect_success '--cherry-mark --left-right' ' | |
124 | git rev-list --cherry-mark --left-right F...E -- bar > actual && | |
125 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
126 | < actual > actual.named && | |
127 | test_cmp actual.named expect | |
128 | ' | |
129 | ||
130 | cat >expect <<EOF | |
59c8afdf MG |
131 | tags/E |
132 | EOF | |
133 | ||
134 | test_expect_success '--cherry-pick --right-only' ' | |
135 | git rev-list --cherry-pick --right-only F...E -- bar > actual && | |
136 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
137 | < actual > actual.named && | |
138 | test_cmp actual.named expect | |
139 | ' | |
140 | ||
141 | test_expect_success '--cherry-pick --left-only' ' | |
142 | git rev-list --cherry-pick --left-only E...F -- bar > actual && | |
e0b9c34f MG |
143 | git name-rev --stdin --name-only --refs="*tags/*" \ |
144 | < actual > actual.named && | |
145 | test_cmp actual.named expect | |
36d56de6 JS |
146 | ' |
147 | ||
fe3b59e5 MG |
148 | cat >expect <<EOF |
149 | +tags/E | |
150 | =tags/C | |
151 | EOF | |
152 | ||
153 | test_expect_success '--cherry' ' | |
154 | git rev-list --cherry F...E -- bar > actual && | |
155 | git name-rev --stdin --name-only --refs="*tags/*" \ | |
156 | < actual > actual.named && | |
157 | test_cmp actual.named expect | |
158 | ' | |
159 | ||
b388e14b MG |
160 | cat >expect <<EOF |
161 | 1 1 | |
162 | EOF | |
163 | ||
164 | test_expect_success '--cherry --count' ' | |
165 | git rev-list --cherry --count F...E -- bar > actual && | |
166 | test_cmp actual expect | |
167 | ' | |
168 | ||
169 | cat >expect <<EOF | |
170 | 2 2 | |
171 | EOF | |
172 | ||
173 | test_expect_success '--cherry-mark --count' ' | |
174 | git rev-list --cherry-mark --count F...E -- bar > actual && | |
175 | test_cmp actual expect | |
176 | ' | |
177 | ||
178 | cat >expect <<EOF | |
179 | 1 1 2 | |
180 | EOF | |
181 | ||
182 | test_expect_success '--cherry-mark --left-right --count' ' | |
183 | git rev-list --cherry-mark --left-right --count F...E -- bar > actual && | |
184 | test_cmp actual expect | |
185 | ' | |
186 | ||
023756f4 JS |
187 | test_expect_success '--cherry-pick with independent, but identical branches' ' |
188 | git symbolic-ref HEAD refs/heads/independent && | |
189 | rm .git/index && | |
190 | echo Hallo > foo && | |
191 | git add foo && | |
192 | test_tick && | |
193 | git commit -m "independent" && | |
194 | echo Bello > foo && | |
195 | test_tick && | |
196 | git commit -m "independent, too" foo && | |
197 | test -z "$(git rev-list --left-right --cherry-pick \ | |
198 | HEAD...master -- foo)" | |
199 | ' | |
200 | ||
f69c5018 TR |
201 | cat >expect <<EOF |
202 | 1 2 | |
203 | EOF | |
204 | ||
f69c5018 | 205 | test_expect_success '--count --left-right' ' |
e0b9c34f | 206 | git rev-list --count --left-right C...D > actual && |
f69c5018 TR |
207 | test_cmp expect actual |
208 | ' | |
209 | ||
36d56de6 | 210 | test_done |