cherry-pick: check commit error messages
We disallow partial commits and amending when CHERRY_PICK_HEAD exists. Add a couple of tests to check the error message printed in each case before we refactor the code responsible for this. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Phillip Wood committed
Dec 6, 2019 at 16:06 UTC
f028d661c74f29de0e26494e6c9fbcf186b0d4ae
1 file changed
+23
t/t3507-cherry-pick-conflict.sh
+23
@@ -161,6 +161,29 @@ test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
161
162
test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
163
'
164
+
165
+test_expect_success 'partial commit of cherry-pick fails' '
166
+ pristine_detach initial &&
167
+
168
+ test_must_fail git cherry-pick picked &&
169
+ echo resolved >foo &&
170
+ git add foo &&
171
+ test_must_fail git commit foo 2>err &&
172
+
173
+ test_i18ngrep "cannot do a partial commit during a cherry-pick." err
174
+'
175
+
176
+test_expect_success 'commit --amend of cherry-pick fails' '
177
+ pristine_detach initial &&
178
+
179
+ test_must_fail git cherry-pick picked &&
180
+ echo resolved >foo &&
181
+ git add foo &&
182
+ test_must_fail git commit --amend 2>err &&
183
+
184
+ test_i18ngrep "in the middle of a cherry-pick -- cannot amend." err
185
+'
186
+
187
test_expect_success 'successful final commit clears cherry-pick state' '
188
pristine_detach initial &&
189