@@ -14,6 +14,9 @@ test_description='Test cherry-pick continuation features
1414
1515. ./test-lib.sh
1616
17+ # Repeat first match 10 times
18+ _r10=' \1\1\1\1\1\1\1\1\1\1'
19+
1720pristine_detach () {
1821 git cherry-pick --quit &&
1922 git checkout -f " $1 ^0" &&
@@ -43,7 +46,7 @@ test_expect_success setup '
4346
4447test_expect_success ' cherry-pick persists data on failure' '
4548 pristine_detach initial &&
46- test_must_fail git cherry-pick -s base..anotherpick &&
49+ test_expect_code 1 git cherry-pick -s base..anotherpick &&
4750 test_path_is_dir .git/sequencer &&
4851 test_path_is_file .git/sequencer/head &&
4952 test_path_is_file .git/sequencer/todo &&
@@ -64,7 +67,7 @@ test_expect_success 'cherry-pick mid-cherry-pick-sequence' '
6467
6568test_expect_success ' cherry-pick persists opts correctly' '
6669 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 &&
6871 test_path_is_dir .git/sequencer &&
6972 test_path_is_file .git/sequencer/head &&
7073 test_path_is_file .git/sequencer/todo &&
@@ -104,7 +107,7 @@ test_expect_success '--abort requires cherry-pick in progress' '
104107
105108test_expect_success ' --quit cleans up sequencer state' '
106109 pristine_detach initial &&
107- test_must_fail git cherry-pick base..picked &&
110+ test_expect_code 1 git cherry-pick base..picked &&
108111 git cherry-pick --quit &&
109112 test_path_is_missing .git/sequencer
110113'
@@ -118,7 +121,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
118121 :000000 100644 OBJID OBJID A foo
119122 :000000 100644 OBJID OBJID A unrelated
120123 EOF
121- test_must_fail git cherry-pick base..picked &&
124+ test_expect_code 1 git cherry-pick base..picked &&
122125 git cherry-pick --quit &&
123126 test_path_is_missing .git/sequencer &&
124127 test_must_fail git update-index --refresh &&
@@ -132,7 +135,7 @@ test_expect_success '--quit keeps HEAD and conflicted index intact' '
132135
133136test_expect_success ' --abort to cancel multiple cherry-pick' '
134137 pristine_detach initial &&
135- test_must_fail git cherry-pick base..anotherpick &&
138+ test_expect_code 1 git cherry-pick base..anotherpick &&
136139 git cherry-pick --abort &&
137140 test_path_is_missing .git/sequencer &&
138141 test_cmp_rev initial HEAD &&
@@ -142,7 +145,7 @@ test_expect_success '--abort to cancel multiple cherry-pick' '
142145
143146test_expect_success ' --abort to cancel single cherry-pick' '
144147 pristine_detach initial &&
145- test_must_fail git cherry-pick picked &&
148+ test_expect_code 1 git cherry-pick picked &&
146149 git cherry-pick --abort &&
147150 test_path_is_missing .git/sequencer &&
148151 test_cmp_rev initial HEAD &&
@@ -152,7 +155,7 @@ test_expect_success '--abort to cancel single cherry-pick' '
152155
153156test_expect_success ' cherry-pick --abort to cancel multiple revert' '
154157 pristine_detach anotherpick &&
155- test_must_fail git revert base..picked &&
158+ test_expect_code 1 git revert base..picked &&
156159 git cherry-pick --abort &&
157160 test_path_is_missing .git/sequencer &&
158161 test_cmp_rev anotherpick HEAD &&
@@ -162,15 +165,15 @@ test_expect_success 'cherry-pick --abort to cancel multiple revert' '
162165
163166test_expect_success ' revert --abort works, too' '
164167 pristine_detach anotherpick &&
165- test_must_fail git revert base..picked &&
168+ test_expect_code 1 git revert base..picked &&
166169 git revert --abort &&
167170 test_path_is_missing .git/sequencer &&
168171 test_cmp_rev anotherpick HEAD
169172'
170173
171174test_expect_success ' --abort to cancel single revert' '
172175 pristine_detach anotherpick &&
173- test_must_fail git revert picked &&
176+ test_expect_code 1 git revert picked &&
174177 git revert --abort &&
175178 test_path_is_missing .git/sequencer &&
176179 test_cmp_rev anotherpick HEAD &&
@@ -181,7 +184,7 @@ test_expect_success '--abort to cancel single revert' '
181184test_expect_success ' --abort keeps unrelated change, easy case' '
182185 pristine_detach unrelatedpick &&
183186 echo changed >expect &&
184- test_must_fail git cherry-pick picked..yetanotherpick &&
187+ test_expect_code 1 git cherry-pick picked..yetanotherpick &&
185188 echo changed >unrelated &&
186189 git cherry-pick --abort &&
187190 test_cmp expect unrelated
@@ -190,7 +193,7 @@ test_expect_success '--abort keeps unrelated change, easy case' '
190193test_expect_success ' --abort refuses to clobber unrelated change, harder case' '
191194 pristine_detach initial &&
192195 echo changed >expect &&
193- test_must_fail git cherry-pick base..anotherpick &&
196+ test_expect_code 1 git cherry-pick base..anotherpick &&
194197 echo changed >unrelated &&
195198 test_must_fail git cherry-pick --abort &&
196199 test_cmp expect unrelated &&
@@ -205,7 +208,7 @@ test_expect_success '--abort refuses to clobber unrelated change, harder case' '
205208
206209test_expect_success ' cherry-pick still writes sequencer state when one commit is left' '
207210 pristine_detach initial &&
208- test_must_fail git cherry-pick base..picked &&
211+ test_expect_code 1 git cherry-pick base..picked &&
209212 test_path_is_dir .git/sequencer &&
210213 echo "resolved" >foo &&
211214 git add foo &&
@@ -229,7 +232,7 @@ test_expect_success 'cherry-pick still writes sequencer state when one commit is
229232
230233test_expect_success ' --abort after last commit in sequence' '
231234 pristine_detach initial &&
232- test_must_fail git cherry-pick base..picked &&
235+ test_expect_code 1 git cherry-pick base..picked &&
233236 git cherry-pick --abort &&
234237 test_path_is_missing .git/sequencer &&
235238 test_cmp_rev initial HEAD &&
@@ -239,22 +242,22 @@ test_expect_success '--abort after last commit in sequence' '
239242
240243test_expect_success ' cherry-pick does not implicitly stomp an existing operation' '
241244 pristine_detach initial &&
242- test_must_fail git cherry-pick base..anotherpick &&
245+ test_expect_code 1 git cherry-pick base..anotherpick &&
243246 test-chmtime -v +0 .git/sequencer >expect &&
244- test_must_fail git cherry-pick unrelatedpick &&
247+ test_expect_code 128 git cherry-pick unrelatedpick &&
245248 test-chmtime -v +0 .git/sequencer >actual &&
246249 test_cmp expect actual
247250'
248251
249252test_expect_success ' --continue complains when no cherry-pick is in progress' '
250253 pristine_detach initial &&
251- test_must_fail git cherry-pick --continue
254+ test_expect_code 128 git cherry-pick --continue
252255'
253256
254257test_expect_success ' --continue complains when there are unresolved conflicts' '
255258 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
258261'
259262
260263test_expect_success ' --continue of single cherry-pick' '
@@ -318,7 +321,7 @@ test_expect_success '--continue after resolving conflicts' '
318321
319322test_expect_success ' --continue after resolving conflicts and committing' '
320323 pristine_detach initial &&
321- test_must_fail git cherry-pick base..anotherpick &&
324+ test_expect_code 1 git cherry-pick base..anotherpick &&
322325 echo "c" >foo &&
323326 git add foo &&
324327 git commit &&
@@ -368,7 +371,7 @@ test_expect_success 'follow advice and skip nil patch' '
368371
369372test_expect_success ' --continue respects opts' '
370373 pristine_detach initial &&
371- test_must_fail git cherry-pick -x base..anotherpick &&
374+ test_expect_code 1 git cherry-pick -x base..anotherpick &&
372375 echo "c" >foo &&
373376 git add foo &&
374377 git commit &&
@@ -409,7 +412,7 @@ test_expect_success '--continue respects -x in first commit in multi-pick' '
409412
410413test_expect_success ' --signoff is not automatically propagated to resolved conflict' '
411414 pristine_detach initial &&
412- test_must_fail git cherry-pick --signoff base..anotherpick &&
415+ test_expect_code 1 git cherry-pick --signoff base..anotherpick &&
413416 echo "c" >foo &&
414417 git add foo &&
415418 git commit &&
@@ -453,29 +456,65 @@ test_expect_success 'sign-off needs to be reaffirmed after conflict resolution,
453456
454457test_expect_success ' malformed instruction sheet 1' '
455458 pristine_detach initial &&
456- test_must_fail git cherry-pick base..anotherpick &&
459+ test_expect_code 1 git cherry-pick base..anotherpick &&
457460 echo "resolved" >foo &&
458461 git add foo &&
459462 git commit &&
460463 sed "s/pick /pick/" .git/sequencer/todo >new_sheet &&
461464 cp new_sheet .git/sequencer/todo &&
462- test_must_fail git cherry-pick --continue
465+ test_expect_code 128 git cherry-pick --continue
463466'
464467
465468test_expect_success ' malformed instruction sheet 2' '
466469 pristine_detach initial &&
467- test_must_fail git cherry-pick base..anotherpick &&
470+ test_expect_code 1 git cherry-pick base..anotherpick &&
468471 echo "resolved" >foo &&
469472 git add foo &&
470473 git commit &&
471474 sed "s/pick/revert/" .git/sequencer/todo >new_sheet &&
472475 cp new_sheet .git/sequencer/todo &&
473- test_must_fail git cherry-pick --continue
476+ test_expect_code 128 git cherry-pick --continue
474477'
475478
476479test_expect_success ' empty commit set' '
477480 pristine_detach initial &&
478481 test_expect_code 128 git cherry-pick base..base
479482'
480483
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+
481520test_done
0 commit comments