@@ -14,6 +14,9 @@ test_description='Test cherry-pick continuation features
14
14
15
15
. ./test-lib.sh
16
16
17
+ # Repeat first match 10 times
18
+ _r10=' \1\1\1\1\1\1\1\1\1\1'
19
+
17
20
pristine_detach () {
18
21
git cherry-pick --quit &&
19
22
git checkout -f " $1 ^0" &&
@@ -43,7 +46,7 @@ test_expect_success setup '
43
46
44
47
test_expect_success ' cherry-pick persists data on failure' '
45
48
pristine_detach initial &&
46
- test_must_fail git cherry-pick -s base..anotherpick &&
49
+ test_expect_code 1 git cherry-pick -s base..anotherpick &&
47
50
test_path_is_dir .git/sequencer &&
48
51
test_path_is_file .git/sequencer/head &&
49
52
test_path_is_file .git/sequencer/todo &&
@@ -64,7 +67,7 @@ test_expect_success 'cherry-pick mid-cherry-pick-sequence' '
64
67
65
68
test_expect_success ' cherry-pick persists opts correctly' '
66
69
pristine_detach initial &&
67
- test_must_fail git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours base ..anotherpick &&
70
+ test_expect_code 128 git cherry-pick -s -m 1 --strategy=recursive -X patience -X ours initial ..anotherpick &&
68
71
test_path_is_dir .git/sequencer &&
69
72
test_path_is_file .git/sequencer/head &&
70
73
test_path_is_file .git/sequencer/todo &&
@@ -104,7 +107,7 @@ test_expect_success '--abort requires cherry-pick in progress' '
104
107
105
108
test_expect_success ' --quit cleans up sequencer state' '
106
109
pristine_detach initial &&
107
- test_must_fail git cherry-pick base..picked &&
110
+ test_expect_code 1 git cherry-pick base..picked &&
108
111
git cherry-pick --quit &&
109
112
test_path_is_missing .git/sequencer
110
113
'
@@ -118,7 +121,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
118
121
:000000 100644 OBJID OBJID A foo
119
122
:000000 100644 OBJID OBJID A unrelated
120
123
EOF
121
- test_must_fail git cherry-pick base..picked &&
124
+ test_expect_code 1 git cherry-pick base..picked &&
122
125
git cherry-pick --quit &&
123
126
test_path_is_missing .git/sequencer &&
124
127
test_must_fail git update-index --refresh &&
@@ -132,7 +135,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
132
135
133
136
test_expect_success ' --abort to cancel multiple cherry-pick' '
134
137
pristine_detach initial &&
135
- test_must_fail git cherry-pick base..anotherpick &&
138
+ test_expect_code 1 git cherry-pick base..anotherpick &&
136
139
git cherry-pick --abort &&
137
140
test_path_is_missing .git/sequencer &&
138
141
test_cmp_rev initial HEAD &&
@@ -142,7 +145,7 @@ test_expect_success '--abort to cancel multiple cherry-pick' '
142
145
143
146
test_expect_success ' --abort to cancel single cherry-pick' '
144
147
pristine_detach initial &&
145
- test_must_fail git cherry-pick picked &&
148
+ test_expect_code 1 git cherry-pick picked &&
146
149
git cherry-pick --abort &&
147
150
test_path_is_missing .git/sequencer &&
148
151
test_cmp_rev initial HEAD &&
@@ -152,7 +155,7 @@ test_expect_success '--abort to cancel single cherry-pick' '
152
155
153
156
test_expect_success ' cherry-pick --abort to cancel multiple revert' '
154
157
pristine_detach anotherpick &&
155
- test_must_fail git revert base..picked &&
158
+ test_expect_code 1 git revert base..picked &&
156
159
git cherry-pick --abort &&
157
160
test_path_is_missing .git/sequencer &&
158
161
test_cmp_rev anotherpick HEAD &&
@@ -162,15 +165,15 @@ test_expect_success 'cherry-pick --abort to cancel multiple revert' '
162
165
163
166
test_expect_success ' revert --abort works, too' '
164
167
pristine_detach anotherpick &&
165
- test_must_fail git revert base..picked &&
168
+ test_expect_code 1 git revert base..picked &&
166
169
git revert --abort &&
167
170
test_path_is_missing .git/sequencer &&
168
171
test_cmp_rev anotherpick HEAD
169
172
'
170
173
171
174
test_expect_success ' --abort to cancel single revert' '
172
175
pristine_detach anotherpick &&
173
- test_must_fail git revert picked &&
176
+ test_expect_code 1 git revert picked &&
174
177
git revert --abort &&
175
178
test_path_is_missing .git/sequencer &&
176
179
test_cmp_rev anotherpick HEAD &&
@@ -181,7 +184,7 @@ test_expect_success '--abort to cancel single revert' '
181
184
test_expect_success ' --abort keeps unrelated change, easy case' '
182
185
pristine_detach unrelatedpick &&
183
186
echo changed >expect &&
184
- test_must_fail git cherry-pick picked..yetanotherpick &&
187
+ test_expect_code 1 git cherry-pick picked..yetanotherpick &&
185
188
echo changed >unrelated &&
186
189
git cherry-pick --abort &&
187
190
test_cmp expect unrelated
@@ -190,7 +193,7 @@ test_expect_success '--abort keeps unrelated change, easy case' '
190
193
test_expect_success ' --abort refuses to clobber unrelated change, harder case' '
191
194
pristine_detach initial &&
192
195
echo changed >expect &&
193
- test_must_fail git cherry-pick base..anotherpick &&
196
+ test_expect_code 1 git cherry-pick base..anotherpick &&
194
197
echo changed >unrelated &&
195
198
test_must_fail git cherry-pick --abort &&
196
199
test_cmp expect unrelated &&
@@ -205,7 +208,7 @@ test_expect_success '--abort refuses to clobber unrelated change, harder case' '
205
208
206
209
test_expect_success ' cherry-pick still writes sequencer state when one commit is left' '
207
210
pristine_detach initial &&
208
- test_must_fail git cherry-pick base..picked &&
211
+ test_expect_code 1 git cherry-pick base..picked &&
209
212
test_path_is_dir .git/sequencer &&
210
213
echo "resolved" >foo &&
211
214
git add foo &&
@@ -229,7 +232,7 @@ test_expect_success 'cherry-pick still writes sequencer state when one commit is
229
232
230
233
test_expect_success ' --abort after last commit in sequence' '
231
234
pristine_detach initial &&
232
- test_must_fail git cherry-pick base..picked &&
235
+ test_expect_code 1 git cherry-pick base..picked &&
233
236
git cherry-pick --abort &&
234
237
test_path_is_missing .git/sequencer &&
235
238
test_cmp_rev initial HEAD &&
@@ -239,22 +242,22 @@ test_expect_success '--abort after last commit in sequence' '
239
242
240
243
test_expect_success ' cherry-pick does not implicitly stomp an existing operation' '
241
244
pristine_detach initial &&
242
- test_must_fail git cherry-pick base..anotherpick &&
245
+ test_expect_code 1 git cherry-pick base..anotherpick &&
243
246
test-chmtime -v +0 .git/sequencer >expect &&
244
- test_must_fail git cherry-pick unrelatedpick &&
247
+ test_expect_code 128 git cherry-pick unrelatedpick &&
245
248
test-chmtime -v +0 .git/sequencer >actual &&
246
249
test_cmp expect actual
247
250
'
248
251
249
252
test_expect_success ' --continue complains when no cherry-pick is in progress' '
250
253
pristine_detach initial &&
251
- test_must_fail git cherry-pick --continue
254
+ test_expect_code 128 git cherry-pick --continue
252
255
'
253
256
254
257
test_expect_success ' --continue complains when there are unresolved conflicts' '
255
258
pristine_detach initial &&
256
- test_must_fail git cherry-pick base..anotherpick &&
257
- test_must_fail git cherry-pick --continue
259
+ test_expect_code 1 git cherry-pick base..anotherpick &&
260
+ test_expect_code 128 git cherry-pick --continue
258
261
'
259
262
260
263
test_expect_success ' --continue of single cherry-pick' '
@@ -318,7 +321,7 @@ test_expect_success '--continue after resolving conflicts' '
318
321
319
322
test_expect_success ' --continue after resolving conflicts and committing' '
320
323
pristine_detach initial &&
321
- test_must_fail git cherry-pick base..anotherpick &&
324
+ test_expect_code 1 git cherry-pick base..anotherpick &&
322
325
echo "c" >foo &&
323
326
git add foo &&
324
327
git commit &&
@@ -368,7 +371,7 @@ test_expect_success 'follow advice and skip nil patch' '
368
371
369
372
test_expect_success ' --continue respects opts' '
370
373
pristine_detach initial &&
371
- test_must_fail git cherry-pick -x base..anotherpick &&
374
+ test_expect_code 1 git cherry-pick -x base..anotherpick &&
372
375
echo "c" >foo &&
373
376
git add foo &&
374
377
git commit &&
@@ -409,7 +412,7 @@ test_expect_success '--continue respects -x in first commit in multi-pick' '
409
412
410
413
test_expect_success ' --signoff is not automatically propagated to resolved conflict' '
411
414
pristine_detach initial &&
412
- test_must_fail git cherry-pick --signoff base..anotherpick &&
415
+ test_expect_code 1 git cherry-pick --signoff base..anotherpick &&
413
416
echo "c" >foo &&
414
417
git add foo &&
415
418
git commit &&
@@ -453,29 +456,65 @@ test_expect_success 'sign-off needs to be reaffirmed after conflict resolution,
453
456
454
457
test_expect_success ' malformed instruction sheet 1' '
455
458
pristine_detach initial &&
456
- test_must_fail git cherry-pick base..anotherpick &&
459
+ test_expect_code 1 git cherry-pick base..anotherpick &&
457
460
echo "resolved" >foo &&
458
461
git add foo &&
459
462
git commit &&
460
463
sed "s/pick /pick/" .git/sequencer/todo >new_sheet &&
461
464
cp new_sheet .git/sequencer/todo &&
462
- test_must_fail git cherry-pick --continue
465
+ test_expect_code 128 git cherry-pick --continue
463
466
'
464
467
465
468
test_expect_success ' malformed instruction sheet 2' '
466
469
pristine_detach initial &&
467
- test_must_fail git cherry-pick base..anotherpick &&
470
+ test_expect_code 1 git cherry-pick base..anotherpick &&
468
471
echo "resolved" >foo &&
469
472
git add foo &&
470
473
git commit &&
471
474
sed "s/pick/revert/" .git/sequencer/todo >new_sheet &&
472
475
cp new_sheet .git/sequencer/todo &&
473
- test_must_fail git cherry-pick --continue
476
+ test_expect_code 128 git cherry-pick --continue
474
477
'
475
478
476
479
test_expect_success ' empty commit set' '
477
480
pristine_detach initial &&
478
481
test_expect_code 128 git cherry-pick base..base
479
482
'
480
483
484
+ test_expect_success ' malformed instruction sheet 3' '
485
+ pristine_detach initial &&
486
+ test_expect_code 1 git cherry-pick base..anotherpick &&
487
+ echo "resolved" >foo &&
488
+ git add foo &&
489
+ git commit &&
490
+ sed "s/pick \([0-9a-f]*\)/pick $_r10/" .git/sequencer/todo >new_sheet &&
491
+ cp new_sheet .git/sequencer/todo &&
492
+ test_expect_code 128 git cherry-pick --continue
493
+ '
494
+
495
+ test_expect_success ' instruction sheet, fat-fingers version' '
496
+ pristine_detach initial &&
497
+ test_expect_code 1 git cherry-pick base..anotherpick &&
498
+ echo "c" >foo &&
499
+ git add foo &&
500
+ git commit &&
501
+ sed "s/pick \([0-9a-f]*\)/pick \1 /" .git/sequencer/todo >new_sheet &&
502
+ cp new_sheet .git/sequencer/todo &&
503
+ git cherry-pick --continue
504
+ '
505
+
506
+ test_expect_success ' commit descriptions in insn sheet are optional' '
507
+ pristine_detach initial &&
508
+ test_expect_code 1 git cherry-pick base..anotherpick &&
509
+ echo "c" >foo &&
510
+ git add foo &&
511
+ git commit &&
512
+ cut -d" " -f1,2 .git/sequencer/todo >new_sheet &&
513
+ cp new_sheet .git/sequencer/todo &&
514
+ git cherry-pick --continue &&
515
+ test_path_is_missing .git/sequencer &&
516
+ git rev-list HEAD >commits &&
517
+ test_line_count = 4 commits
518
+ '
519
+
481
520
test_done
0 commit comments