]>
Commit | Line | Data |
---|---|---|
04d3d3cf RR |
1 | #!/bin/sh |
2 | ||
3 | test_description='Test cherry-pick continuation features | |
4 | ||
093a3091 | 5 | + conflicting: rewrites unrelated to conflicting |
539047c1 | 6 | + yetanotherpick: rewrites foo to e |
04d3d3cf RR |
7 | + anotherpick: rewrites foo to d |
8 | + picked: rewrites foo to c | |
9 | + unrelatedpick: rewrites unrelated to reallyunrelated | |
10 | + base: rewrites foo to b | |
11 | + initial: writes foo as a, unrelated as unrelated | |
12 | ||
13 | ' | |
14 | ||
15 | . ./test-lib.sh | |
16 | ||
6bc1a235 RR |
17 | # Repeat first match 10 times |
18 | _r10='\1\1\1\1\1\1\1\1\1\1' | |
19 | ||
04d3d3cf | 20 | pristine_detach () { |
f80a8726 | 21 | git cherry-pick --quit && |
04d3d3cf RR |
22 | git checkout -f "$1^0" && |
23 | git read-tree -u --reset HEAD && | |
24 | git clean -d -f -f -q -x | |
25 | } | |
26 | ||
27 | test_expect_success setup ' | |
070bad6d | 28 | git config advice.detachedhead false && |
04d3d3cf RR |
29 | echo unrelated >unrelated && |
30 | git add unrelated && | |
31 | test_commit initial foo a && | |
32 | test_commit base foo b && | |
33 | test_commit unrelatedpick unrelated reallyunrelated && | |
34 | test_commit picked foo c && | |
35 | test_commit anotherpick foo d && | |
539047c1 | 36 | test_commit yetanotherpick foo e && |
093a3091 JN |
37 | pristine_detach initial && |
38 | test_commit conflicting unrelated | |
04d3d3cf RR |
39 | ' |
40 | ||
41 | test_expect_success 'cherry-pick persists data on failure' ' | |
42 | pristine_detach initial && | |
c6b7c7f3 | 43 | test_expect_code 1 git cherry-pick -s base..anotherpick && |
04d3d3cf RR |
44 | test_path_is_dir .git/sequencer && |
45 | test_path_is_file .git/sequencer/head && | |
6f032263 RR |
46 | test_path_is_file .git/sequencer/todo && |
47 | test_path_is_file .git/sequencer/opts | |
48 | ' | |
49 | ||
7acaaac2 JN |
50 | test_expect_success 'cherry-pick mid-cherry-pick-sequence' ' |
51 | pristine_detach initial && | |
52 | test_must_fail git cherry-pick base..anotherpick && | |
53 | test_cmp_rev picked CHERRY_PICK_HEAD && | |
54 | # "oops, I forgot that these patches rely on the change from base" | |
55 | git checkout HEAD foo && | |
56 | git cherry-pick base && | |
57 | git cherry-pick picked && | |
58 | git cherry-pick --continue && | |
59 | git diff --exit-code anotherpick | |
60 | ' | |
61 | ||
6f032263 RR |
62 | test_expect_success 'cherry-pick persists opts correctly' ' |
63 | pristine_detach initial && | |
c812bd46 SO |
64 | # to make sure that the session to cherry-pick a sequence |
65 | # gets interrupted, use a high-enough number that is larger | |
66 | # than the number of parents of any commit we have created | |
67 | mainline=4 && | |
39edfd5c | 68 | test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X ours --edit initial..anotherpick && |
6f032263 RR |
69 | test_path_is_dir .git/sequencer && |
70 | test_path_is_file .git/sequencer/head && | |
71 | test_path_is_file .git/sequencer/todo && | |
72 | test_path_is_file .git/sequencer/opts && | |
73 | echo "true" >expect && | |
74 | git config --file=.git/sequencer/opts --get-all options.signoff >actual && | |
75 | test_cmp expect actual && | |
c812bd46 | 76 | echo "$mainline" >expect && |
6f032263 RR |
77 | git config --file=.git/sequencer/opts --get-all options.mainline >actual && |
78 | test_cmp expect actual && | |
79 | echo "recursive" >expect && | |
80 | git config --file=.git/sequencer/opts --get-all options.strategy >actual && | |
81 | test_cmp expect actual && | |
82 | cat >expect <<-\EOF && | |
83 | patience | |
84 | ours | |
85 | EOF | |
86 | git config --file=.git/sequencer/opts --get-all options.strategy-option >actual && | |
39edfd5c EN |
87 | test_cmp expect actual && |
88 | echo "true" >expect && | |
89 | git config --file=.git/sequencer/opts --get-all options.edit >actual && | |
90 | test_cmp expect actual | |
91 | ' | |
92 | ||
93 | test_expect_success 'revert persists opts correctly' ' | |
94 | pristine_detach initial && | |
95 | # to make sure that the session to revert a sequence | |
96 | # gets interrupted, revert commits that are not in the history | |
97 | # of HEAD. | |
98 | test_expect_code 1 git revert -s --strategy=recursive -X patience -X ours --no-edit picked yetanotherpick && | |
99 | test_path_is_dir .git/sequencer && | |
100 | test_path_is_file .git/sequencer/head && | |
101 | test_path_is_file .git/sequencer/todo && | |
102 | test_path_is_file .git/sequencer/opts && | |
103 | echo "true" >expect && | |
104 | git config --file=.git/sequencer/opts --get-all options.signoff >actual && | |
105 | test_cmp expect actual && | |
106 | echo "recursive" >expect && | |
107 | git config --file=.git/sequencer/opts --get-all options.strategy >actual && | |
108 | test_cmp expect actual && | |
109 | cat >expect <<-\EOF && | |
110 | patience | |
111 | ours | |
112 | EOF | |
113 | git config --file=.git/sequencer/opts --get-all options.strategy-option >actual && | |
114 | test_cmp expect actual && | |
115 | echo "false" >expect && | |
116 | git config --file=.git/sequencer/opts --get-all options.edit >actual && | |
6f032263 | 117 | test_cmp expect actual |
04d3d3cf RR |
118 | ' |
119 | ||
120 | test_expect_success 'cherry-pick cleans up sequencer state upon success' ' | |
121 | pristine_detach initial && | |
122 | git cherry-pick initial..picked && | |
123 | test_path_is_missing .git/sequencer | |
124 | ' | |
125 | ||
de81ca3f RA |
126 | test_expect_success 'cherry-pick --skip requires cherry-pick in progress' ' |
127 | pristine_detach initial && | |
128 | test_must_fail git cherry-pick --skip | |
129 | ' | |
130 | ||
131 | test_expect_success 'revert --skip requires revert in progress' ' | |
132 | pristine_detach initial && | |
133 | test_must_fail git revert --skip | |
134 | ' | |
135 | ||
136 | test_expect_success 'cherry-pick --skip to skip commit' ' | |
137 | pristine_detach initial && | |
138 | test_must_fail git cherry-pick anotherpick && | |
139 | test_must_fail git revert --skip && | |
140 | git cherry-pick --skip && | |
141 | test_cmp_rev initial HEAD && | |
142 | test_path_is_missing .git/CHERRY_PICK_HEAD | |
143 | ' | |
144 | ||
145 | test_expect_success 'revert --skip to skip commit' ' | |
146 | pristine_detach anotherpick && | |
147 | test_must_fail git revert anotherpick~1 && | |
148 | test_must_fail git cherry-pick --skip && | |
149 | git revert --skip && | |
150 | test_cmp_rev anotherpick HEAD | |
151 | ' | |
152 | ||
153 | test_expect_success 'skip "empty" commit' ' | |
154 | pristine_detach picked && | |
155 | test_commit dummy foo d && | |
5b7a64df | 156 | test_must_fail git cherry-pick anotherpick 2>err && |
6789275d | 157 | test_grep "git cherry-pick --skip" err && |
de81ca3f RA |
158 | git cherry-pick --skip && |
159 | test_cmp_rev dummy HEAD | |
160 | ' | |
161 | ||
162 | test_expect_success 'skip a commit and check if rest of sequence is correct' ' | |
163 | pristine_detach initial && | |
164 | echo e >expect && | |
165 | cat >expect.log <<-EOF && | |
166 | OBJID | |
167 | :100644 100644 OBJID OBJID M foo | |
168 | OBJID | |
169 | :100644 100644 OBJID OBJID M foo | |
170 | OBJID | |
171 | :100644 100644 OBJID OBJID M unrelated | |
172 | OBJID | |
173 | :000000 100644 OBJID OBJID A foo | |
174 | :000000 100644 OBJID OBJID A unrelated | |
175 | EOF | |
176 | test_must_fail git cherry-pick base..yetanotherpick && | |
177 | test_must_fail git cherry-pick --skip && | |
178 | echo d >foo && | |
179 | git add foo && | |
180 | git cherry-pick --continue && | |
181 | { | |
182 | git rev-list HEAD | | |
183 | git diff-tree --root --stdin | | |
184 | sed "s/$OID_REGEX/OBJID/g" | |
185 | } >actual.log && | |
186 | test_cmp expect foo && | |
187 | test_cmp expect.log actual.log | |
188 | ' | |
189 | ||
190 | test_expect_success 'check advice when we move HEAD by committing' ' | |
191 | pristine_detach initial && | |
192 | cat >expect <<-EOF && | |
193 | error: there is nothing to skip | |
194 | hint: have you committed already? | |
195 | hint: try "git cherry-pick --continue" | |
196 | fatal: cherry-pick failed | |
197 | EOF | |
198 | test_must_fail git cherry-pick base..yetanotherpick && | |
199 | echo c >foo && | |
200 | git commit -a && | |
201 | test_path_is_missing .git/CHERRY_PICK_HEAD && | |
202 | test_must_fail git cherry-pick --skip 2>advice && | |
1108cea7 | 203 | test_cmp expect advice |
de81ca3f RA |
204 | ' |
205 | ||
dcb500dc RA |
206 | test_expect_success 'selectively advise --skip while launching another sequence' ' |
207 | pristine_detach initial && | |
208 | cat >expect <<-EOF && | |
209 | error: cherry-pick is already in progress | |
210 | hint: try "git cherry-pick (--continue | --skip | --abort | --quit)" | |
211 | fatal: cherry-pick failed | |
212 | EOF | |
213 | test_must_fail git cherry-pick picked..yetanotherpick && | |
214 | test_must_fail git cherry-pick picked..yetanotherpick 2>advice && | |
1108cea7 | 215 | test_cmp expect advice && |
dcb500dc RA |
216 | cat >expect <<-EOF && |
217 | error: cherry-pick is already in progress | |
218 | hint: try "git cherry-pick (--continue | --abort | --quit)" | |
219 | fatal: cherry-pick failed | |
220 | EOF | |
221 | git reset --merge && | |
222 | test_must_fail git cherry-pick picked..yetanotherpick 2>advice && | |
1108cea7 | 223 | test_cmp expect advice |
dcb500dc RA |
224 | ' |
225 | ||
de81ca3f RA |
226 | test_expect_success 'allow skipping commit but not abort for a new history' ' |
227 | pristine_detach initial && | |
228 | cat >expect <<-EOF && | |
229 | error: cannot abort from a branch yet to be born | |
230 | fatal: cherry-pick failed | |
231 | EOF | |
232 | git checkout --orphan new_disconnected && | |
233 | git reset --hard && | |
234 | test_must_fail git cherry-pick anotherpick && | |
235 | test_must_fail git cherry-pick --abort 2>advice && | |
236 | git cherry-pick --skip && | |
1108cea7 | 237 | test_cmp expect advice |
de81ca3f RA |
238 | ' |
239 | ||
240 | test_expect_success 'allow skipping stopped cherry-pick because of untracked file modifications' ' | |
f222bd34 | 241 | test_when_finished "rm unrelated" && |
de81ca3f RA |
242 | pristine_detach initial && |
243 | git rm --cached unrelated && | |
244 | git commit -m "untrack unrelated" && | |
245 | test_must_fail git cherry-pick initial base && | |
246 | test_path_is_missing .git/CHERRY_PICK_HEAD && | |
247 | git cherry-pick --skip | |
248 | ' | |
249 | ||
f80a8726 | 250 | test_expect_success '--quit does not complain when no cherry-pick is in progress' ' |
26ae337b | 251 | pristine_detach initial && |
f80a8726 | 252 | git cherry-pick --quit |
26ae337b RR |
253 | ' |
254 | ||
539047c1 JN |
255 | test_expect_success '--abort requires cherry-pick in progress' ' |
256 | pristine_detach initial && | |
257 | test_must_fail git cherry-pick --abort | |
258 | ' | |
259 | ||
f80a8726 | 260 | test_expect_success '--quit cleans up sequencer state' ' |
26ae337b | 261 | pristine_detach initial && |
c6b7c7f3 | 262 | test_expect_code 1 git cherry-pick base..picked && |
f80a8726 | 263 | git cherry-pick --quit && |
3e7dd992 NTND |
264 | test_path_is_missing .git/sequencer && |
265 | test_path_is_missing .git/CHERRY_PICK_HEAD | |
26ae337b RR |
266 | ' |
267 | ||
c427b211 | 268 | test_expect_success '--quit keeps HEAD and conflicted index intact' ' |
f80a8726 JN |
269 | pristine_detach initial && |
270 | cat >expect <<-\EOF && | |
271 | OBJID | |
272 | :100644 100644 OBJID OBJID M unrelated | |
273 | OBJID | |
274 | :000000 100644 OBJID OBJID A foo | |
275 | :000000 100644 OBJID OBJID A unrelated | |
276 | EOF | |
c6b7c7f3 | 277 | test_expect_code 1 git cherry-pick base..picked && |
c427b211 | 278 | git cherry-pick --quit && |
f80a8726 JN |
279 | test_path_is_missing .git/sequencer && |
280 | test_must_fail git update-index --refresh && | |
281 | { | |
282 | git rev-list HEAD | | |
283 | git diff-tree --root --stdin | | |
2ece6ad2 | 284 | sed "s/$OID_REGEX/OBJID/g" |
f80a8726 JN |
285 | } >actual && |
286 | test_cmp expect actual | |
287 | ' | |
288 | ||
539047c1 JN |
289 | test_expect_success '--abort to cancel multiple cherry-pick' ' |
290 | pristine_detach initial && | |
c6b7c7f3 | 291 | test_expect_code 1 git cherry-pick base..anotherpick && |
539047c1 JN |
292 | git cherry-pick --abort && |
293 | test_path_is_missing .git/sequencer && | |
3e7dd992 | 294 | test_path_is_missing .git/CHERRY_PICK_HEAD && |
539047c1 JN |
295 | test_cmp_rev initial HEAD && |
296 | git update-index --refresh && | |
297 | git diff-index --exit-code HEAD | |
298 | ' | |
299 | ||
300 | test_expect_success '--abort to cancel single cherry-pick' ' | |
301 | pristine_detach initial && | |
c6b7c7f3 | 302 | test_expect_code 1 git cherry-pick picked && |
539047c1 JN |
303 | git cherry-pick --abort && |
304 | test_path_is_missing .git/sequencer && | |
3e7dd992 | 305 | test_path_is_missing .git/CHERRY_PICK_HEAD && |
539047c1 JN |
306 | test_cmp_rev initial HEAD && |
307 | git update-index --refresh && | |
308 | git diff-index --exit-code HEAD | |
309 | ' | |
310 | ||
1e41229d | 311 | test_expect_success '--abort does not unsafely change HEAD' ' |
aeebd98e SB |
312 | pristine_detach initial && |
313 | test_must_fail git cherry-pick picked anotherpick && | |
314 | git reset --hard base && | |
315 | test_must_fail git cherry-pick picked anotherpick && | |
316 | git cherry-pick --abort 2>actual && | |
6789275d | 317 | test_grep "You seem to have moved HEAD" actual && |
aeebd98e SB |
318 | test_cmp_rev base HEAD |
319 | ' | |
320 | ||
539047c1 JN |
321 | test_expect_success 'cherry-pick --abort to cancel multiple revert' ' |
322 | pristine_detach anotherpick && | |
c6b7c7f3 | 323 | test_expect_code 1 git revert base..picked && |
539047c1 JN |
324 | git cherry-pick --abort && |
325 | test_path_is_missing .git/sequencer && | |
3e7dd992 | 326 | test_path_is_missing .git/CHERRY_PICK_HEAD && |
539047c1 JN |
327 | test_cmp_rev anotherpick HEAD && |
328 | git update-index --refresh && | |
329 | git diff-index --exit-code HEAD | |
330 | ' | |
331 | ||
332 | test_expect_success 'revert --abort works, too' ' | |
333 | pristine_detach anotherpick && | |
c6b7c7f3 | 334 | test_expect_code 1 git revert base..picked && |
539047c1 JN |
335 | git revert --abort && |
336 | test_path_is_missing .git/sequencer && | |
337 | test_cmp_rev anotherpick HEAD | |
338 | ' | |
339 | ||
340 | test_expect_success '--abort to cancel single revert' ' | |
341 | pristine_detach anotherpick && | |
c6b7c7f3 | 342 | test_expect_code 1 git revert picked && |
539047c1 JN |
343 | git revert --abort && |
344 | test_path_is_missing .git/sequencer && | |
345 | test_cmp_rev anotherpick HEAD && | |
346 | git update-index --refresh && | |
347 | git diff-index --exit-code HEAD | |
348 | ' | |
349 | ||
350 | test_expect_success '--abort keeps unrelated change, easy case' ' | |
351 | pristine_detach unrelatedpick && | |
352 | echo changed >expect && | |
c6b7c7f3 | 353 | test_expect_code 1 git cherry-pick picked..yetanotherpick && |
539047c1 JN |
354 | echo changed >unrelated && |
355 | git cherry-pick --abort && | |
356 | test_cmp expect unrelated | |
357 | ' | |
358 | ||
359 | test_expect_success '--abort refuses to clobber unrelated change, harder case' ' | |
360 | pristine_detach initial && | |
361 | echo changed >expect && | |
c6b7c7f3 | 362 | test_expect_code 1 git cherry-pick base..anotherpick && |
539047c1 JN |
363 | echo changed >unrelated && |
364 | test_must_fail git cherry-pick --abort && | |
365 | test_cmp expect unrelated && | |
366 | git rev-list HEAD >log && | |
367 | test_line_count = 2 log && | |
368 | test_must_fail git update-index --refresh && | |
369 | ||
370 | git checkout unrelated && | |
371 | git cherry-pick --abort && | |
372 | test_cmp_rev initial HEAD | |
373 | ' | |
374 | ||
218b65fb | 375 | test_expect_success 'cherry-pick still writes sequencer state when one commit is left' ' |
2d27daa9 | 376 | pristine_detach initial && |
c6b7c7f3 | 377 | test_expect_code 1 git cherry-pick base..picked && |
218b65fb | 378 | test_path_is_dir .git/sequencer && |
2d27daa9 RR |
379 | echo "resolved" >foo && |
380 | git add foo && | |
381 | git commit && | |
382 | { | |
383 | git rev-list HEAD | | |
384 | git diff-tree --root --stdin | | |
2ece6ad2 | 385 | sed "s/$OID_REGEX/OBJID/g" |
2d27daa9 RR |
386 | } >actual && |
387 | cat >expect <<-\EOF && | |
388 | OBJID | |
389 | :100644 100644 OBJID OBJID M foo | |
390 | OBJID | |
391 | :100644 100644 OBJID OBJID M unrelated | |
392 | OBJID | |
393 | :000000 100644 OBJID OBJID A foo | |
394 | :000000 100644 OBJID OBJID A unrelated | |
395 | EOF | |
396 | test_cmp expect actual | |
397 | ' | |
398 | ||
218b65fb | 399 | test_expect_success '--abort after last commit in sequence' ' |
539047c1 | 400 | pristine_detach initial && |
c6b7c7f3 | 401 | test_expect_code 1 git cherry-pick base..picked && |
539047c1 JN |
402 | git cherry-pick --abort && |
403 | test_path_is_missing .git/sequencer && | |
3e7dd992 | 404 | test_path_is_missing .git/CHERRY_PICK_HEAD && |
539047c1 JN |
405 | test_cmp_rev initial HEAD && |
406 | git update-index --refresh && | |
407 | git diff-index --exit-code HEAD | |
408 | ' | |
409 | ||
21afd080 RR |
410 | test_expect_success 'cherry-pick does not implicitly stomp an existing operation' ' |
411 | pristine_detach initial && | |
c6b7c7f3 | 412 | test_expect_code 1 git cherry-pick base..anotherpick && |
deb9845a | 413 | test-tool chmtime --get .git/sequencer >expect && |
c6b7c7f3 | 414 | test_expect_code 128 git cherry-pick unrelatedpick && |
deb9845a | 415 | test-tool chmtime --get .git/sequencer >actual && |
21afd080 RR |
416 | test_cmp expect actual |
417 | ' | |
418 | ||
5a5d80f4 RR |
419 | test_expect_success '--continue complains when no cherry-pick is in progress' ' |
420 | pristine_detach initial && | |
c6b7c7f3 | 421 | test_expect_code 128 git cherry-pick --continue |
5a5d80f4 RR |
422 | ' |
423 | ||
424 | test_expect_success '--continue complains when there are unresolved conflicts' ' | |
425 | pristine_detach initial && | |
c6b7c7f3 RR |
426 | test_expect_code 1 git cherry-pick base..anotherpick && |
427 | test_expect_code 128 git cherry-pick --continue | |
5a5d80f4 RR |
428 | ' |
429 | ||
093a3091 JN |
430 | test_expect_success '--continue of single cherry-pick' ' |
431 | pristine_detach initial && | |
432 | echo c >expect && | |
433 | test_must_fail git cherry-pick picked && | |
434 | echo c >foo && | |
435 | git add foo && | |
436 | git cherry-pick --continue && | |
437 | ||
438 | test_cmp expect foo && | |
439 | test_cmp_rev initial HEAD^ && | |
440 | git diff --exit-code HEAD && | |
441 | test_must_fail git rev-parse --verify CHERRY_PICK_HEAD | |
442 | ' | |
443 | ||
444 | test_expect_success '--continue of single revert' ' | |
445 | pristine_detach initial && | |
446 | echo resolved >expect && | |
447 | echo "Revert \"picked\"" >expect.msg && | |
448 | test_must_fail git revert picked && | |
449 | echo resolved >foo && | |
450 | git add foo && | |
451 | git cherry-pick --continue && | |
452 | ||
453 | git diff --exit-code HEAD && | |
454 | test_cmp expect foo && | |
455 | test_cmp_rev initial HEAD^ && | |
456 | git diff-tree -s --pretty=tformat:%s HEAD >msg && | |
457 | test_cmp expect.msg msg && | |
458 | test_must_fail git rev-parse --verify CHERRY_PICK_HEAD && | |
459 | test_must_fail git rev-parse --verify REVERT_HEAD | |
460 | ' | |
461 | ||
462 | test_expect_success '--continue after resolving conflicts' ' | |
463 | pristine_detach initial && | |
464 | echo d >expect && | |
465 | cat >expect.log <<-\EOF && | |
466 | OBJID | |
467 | :100644 100644 OBJID OBJID M foo | |
468 | OBJID | |
469 | :100644 100644 OBJID OBJID M foo | |
470 | OBJID | |
471 | :100644 100644 OBJID OBJID M unrelated | |
472 | OBJID | |
473 | :000000 100644 OBJID OBJID A foo | |
474 | :000000 100644 OBJID OBJID A unrelated | |
475 | EOF | |
476 | test_must_fail git cherry-pick base..anotherpick && | |
477 | echo c >foo && | |
478 | git add foo && | |
479 | git cherry-pick --continue && | |
480 | { | |
481 | git rev-list HEAD | | |
482 | git diff-tree --root --stdin | | |
2ece6ad2 | 483 | sed "s/$OID_REGEX/OBJID/g" |
093a3091 JN |
484 | } >actual.log && |
485 | test_cmp expect foo && | |
486 | test_cmp expect.log actual.log | |
487 | ' | |
488 | ||
489 | test_expect_success '--continue after resolving conflicts and committing' ' | |
5a5d80f4 | 490 | pristine_detach initial && |
c6b7c7f3 | 491 | test_expect_code 1 git cherry-pick base..anotherpick && |
5a5d80f4 RR |
492 | echo "c" >foo && |
493 | git add foo && | |
494 | git commit && | |
495 | git cherry-pick --continue && | |
496 | test_path_is_missing .git/sequencer && | |
497 | { | |
498 | git rev-list HEAD | | |
499 | git diff-tree --root --stdin | | |
2ece6ad2 | 500 | sed "s/$OID_REGEX/OBJID/g" |
5a5d80f4 RR |
501 | } >actual && |
502 | cat >expect <<-\EOF && | |
503 | OBJID | |
504 | :100644 100644 OBJID OBJID M foo | |
505 | OBJID | |
506 | :100644 100644 OBJID OBJID M foo | |
507 | OBJID | |
508 | :100644 100644 OBJID OBJID M unrelated | |
509 | OBJID | |
510 | :000000 100644 OBJID OBJID A foo | |
511 | :000000 100644 OBJID OBJID A unrelated | |
512 | EOF | |
513 | test_cmp expect actual | |
514 | ' | |
515 | ||
093a3091 JN |
516 | test_expect_success '--continue asks for help after resolving patch to nil' ' |
517 | pristine_detach conflicting && | |
518 | test_must_fail git cherry-pick initial..picked && | |
519 | ||
520 | test_cmp_rev unrelatedpick CHERRY_PICK_HEAD && | |
521 | git checkout HEAD -- unrelated && | |
522 | test_must_fail git cherry-pick --continue 2>msg && | |
6789275d | 523 | test_grep "The previous cherry-pick is now empty" msg |
093a3091 JN |
524 | ' |
525 | ||
a7eff1e0 | 526 | test_expect_success 'follow advice and skip nil patch' ' |
093a3091 JN |
527 | pristine_detach conflicting && |
528 | test_must_fail git cherry-pick initial..picked && | |
529 | ||
530 | git checkout HEAD -- unrelated && | |
531 | test_must_fail git cherry-pick --continue && | |
532 | git reset && | |
533 | git cherry-pick --continue && | |
534 | ||
535 | git rev-list initial..HEAD >commits && | |
536 | test_line_count = 3 commits | |
537 | ' | |
538 | ||
5a5d80f4 RR |
539 | test_expect_success '--continue respects opts' ' |
540 | pristine_detach initial && | |
c6b7c7f3 | 541 | test_expect_code 1 git cherry-pick -x base..anotherpick && |
5a5d80f4 RR |
542 | echo "c" >foo && |
543 | git add foo && | |
544 | git commit && | |
545 | git cherry-pick --continue && | |
546 | test_path_is_missing .git/sequencer && | |
547 | git cat-file commit HEAD >anotherpick_msg && | |
548 | git cat-file commit HEAD~1 >picked_msg && | |
549 | git cat-file commit HEAD~2 >unrelatedpick_msg && | |
550 | git cat-file commit HEAD~3 >initial_msg && | |
c7cf9566 | 551 | ! grep "cherry picked from" initial_msg && |
5a5d80f4 RR |
552 | grep "cherry picked from" unrelatedpick_msg && |
553 | grep "cherry picked from" picked_msg && | |
554 | grep "cherry picked from" anotherpick_msg | |
555 | ' | |
556 | ||
093a3091 JN |
557 | test_expect_success '--continue of single-pick respects -x' ' |
558 | pristine_detach initial && | |
559 | test_must_fail git cherry-pick -x picked && | |
560 | echo c >foo && | |
561 | git add foo && | |
562 | git cherry-pick --continue && | |
563 | test_path_is_missing .git/sequencer && | |
564 | git cat-file commit HEAD >msg && | |
565 | grep "cherry picked from" msg | |
566 | ' | |
567 | ||
568 | test_expect_success '--continue respects -x in first commit in multi-pick' ' | |
569 | pristine_detach initial && | |
570 | test_must_fail git cherry-pick -x picked anotherpick && | |
571 | echo c >foo && | |
572 | git add foo && | |
573 | git cherry-pick --continue && | |
574 | test_path_is_missing .git/sequencer && | |
575 | git cat-file commit HEAD^ >msg && | |
576 | picked=$(git rev-parse --verify picked) && | |
577 | grep "cherry picked from.*$picked" msg | |
578 | ' | |
579 | ||
5ed75e2a | 580 | test_expect_failure '--signoff is automatically propagated to resolved conflict' ' |
5a5d80f4 | 581 | pristine_detach initial && |
c6b7c7f3 | 582 | test_expect_code 1 git cherry-pick --signoff base..anotherpick && |
5a5d80f4 RR |
583 | echo "c" >foo && |
584 | git add foo && | |
585 | git commit && | |
586 | git cherry-pick --continue && | |
587 | test_path_is_missing .git/sequencer && | |
588 | git cat-file commit HEAD >anotherpick_msg && | |
589 | git cat-file commit HEAD~1 >picked_msg && | |
590 | git cat-file commit HEAD~2 >unrelatedpick_msg && | |
591 | git cat-file commit HEAD~3 >initial_msg && | |
c7cf9566 | 592 | ! grep "Signed-off-by:" initial_msg && |
5a5d80f4 | 593 | grep "Signed-off-by:" unrelatedpick_msg && |
c7cf9566 | 594 | ! grep "Signed-off-by:" picked_msg && |
5a5d80f4 RR |
595 | grep "Signed-off-by:" anotherpick_msg |
596 | ' | |
597 | ||
5ed75e2a | 598 | test_expect_failure '--signoff dropped for implicit commit of resolution, multi-pick case' ' |
093a3091 JN |
599 | pristine_detach initial && |
600 | test_must_fail git cherry-pick -s picked anotherpick && | |
601 | echo c >foo && | |
602 | git add foo && | |
603 | git cherry-pick --continue && | |
604 | ||
605 | git diff --exit-code HEAD && | |
606 | test_cmp_rev initial HEAD^^ && | |
607 | git cat-file commit HEAD^ >msg && | |
608 | ! grep Signed-off-by: msg | |
609 | ' | |
610 | ||
5ed75e2a | 611 | test_expect_failure 'sign-off needs to be reaffirmed after conflict resolution, single-pick case' ' |
093a3091 JN |
612 | pristine_detach initial && |
613 | test_must_fail git cherry-pick -s picked && | |
614 | echo c >foo && | |
615 | git add foo && | |
616 | git cherry-pick --continue && | |
617 | ||
618 | git diff --exit-code HEAD && | |
619 | test_cmp_rev initial HEAD^ && | |
620 | git cat-file commit HEAD >msg && | |
621 | ! grep Signed-off-by: msg | |
622 | ' | |
623 | ||
5a5d80f4 RR |
624 | test_expect_success 'malformed instruction sheet 1' ' |
625 | pristine_detach initial && | |
c6b7c7f3 | 626 | test_expect_code 1 git cherry-pick base..anotherpick && |
5a5d80f4 RR |
627 | echo "resolved" >foo && |
628 | git add foo && | |
629 | git commit && | |
630 | sed "s/pick /pick/" .git/sequencer/todo >new_sheet && | |
631 | cp new_sheet .git/sequencer/todo && | |
c6b7c7f3 | 632 | test_expect_code 128 git cherry-pick --continue |
5a5d80f4 RR |
633 | ' |
634 | ||
635 | test_expect_success 'malformed instruction sheet 2' ' | |
636 | pristine_detach initial && | |
c6b7c7f3 | 637 | test_expect_code 1 git cherry-pick base..anotherpick && |
5a5d80f4 RR |
638 | echo "resolved" >foo && |
639 | git add foo && | |
640 | git commit && | |
641 | sed "s/pick/revert/" .git/sequencer/todo >new_sheet && | |
642 | cp new_sheet .git/sequencer/todo && | |
c6b7c7f3 | 643 | test_expect_code 128 git cherry-pick --continue |
5a5d80f4 RR |
644 | ' |
645 | ||
8530c739 | 646 | test_expect_success 'empty commit set (no commits to walk)' ' |
7f13334e JN |
647 | pristine_detach initial && |
648 | test_expect_code 128 git cherry-pick base..base | |
649 | ' | |
650 | ||
8530c739 JK |
651 | test_expect_success 'empty commit set (culled during walk)' ' |
652 | pristine_detach initial && | |
653 | test_expect_code 128 git cherry-pick -2 --author=no.such.author base | |
654 | ' | |
655 | ||
6bc1a235 RR |
656 | test_expect_success 'malformed instruction sheet 3' ' |
657 | pristine_detach initial && | |
c6b7c7f3 | 658 | test_expect_code 1 git cherry-pick base..anotherpick && |
6bc1a235 RR |
659 | echo "resolved" >foo && |
660 | git add foo && | |
661 | git commit && | |
662 | sed "s/pick \([0-9a-f]*\)/pick $_r10/" .git/sequencer/todo >new_sheet && | |
663 | cp new_sheet .git/sequencer/todo && | |
c6b7c7f3 | 664 | test_expect_code 128 git cherry-pick --continue |
6bc1a235 RR |
665 | ' |
666 | ||
0db76962 RR |
667 | test_expect_success 'instruction sheet, fat-fingers version' ' |
668 | pristine_detach initial && | |
c6b7c7f3 | 669 | test_expect_code 1 git cherry-pick base..anotherpick && |
0db76962 RR |
670 | echo "c" >foo && |
671 | git add foo && | |
672 | git commit && | |
673 | sed "s/pick \([0-9a-f]*\)/pick \1 /" .git/sequencer/todo >new_sheet && | |
674 | cp new_sheet .git/sequencer/todo && | |
675 | git cherry-pick --continue | |
676 | ' | |
677 | ||
6bc1a235 RR |
678 | test_expect_success 'commit descriptions in insn sheet are optional' ' |
679 | pristine_detach initial && | |
c6b7c7f3 | 680 | test_expect_code 1 git cherry-pick base..anotherpick && |
6bc1a235 RR |
681 | echo "c" >foo && |
682 | git add foo && | |
683 | git commit && | |
684 | cut -d" " -f1,2 .git/sequencer/todo >new_sheet && | |
685 | cp new_sheet .git/sequencer/todo && | |
686 | git cherry-pick --continue && | |
687 | test_path_is_missing .git/sequencer && | |
688 | git rev-list HEAD >commits && | |
689 | test_line_count = 4 commits | |
690 | ' | |
691 | ||
04d3d3cf | 692 | test_done |