]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cherry-pick: check commit error messages
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 6 Dec 2019 16:06:08 +0000 (16:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Dec 2019 17:32:01 +0000 (09:32 -0800)
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>
t/t3507-cherry-pick-conflict.sh

index 9b9b4ca8d4f2a2188c206a0e1e2de763d00a1ab6..c9715bf674cca3ab83646b5e5d1b868ba450b376 100755 (executable)
@@ -161,6 +161,29 @@ test_expect_success 'successful commit clears CHERRY_PICK_HEAD' '
 
        test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
 '
+
+test_expect_success 'partial commit of cherry-pick fails' '
+       pristine_detach initial &&
+
+       test_must_fail git cherry-pick picked &&
+       echo resolved >foo &&
+       git add foo &&
+       test_must_fail git commit foo 2>err &&
+
+       test_i18ngrep "cannot do a partial commit during a cherry-pick." err
+'
+
+test_expect_success 'commit --amend of cherry-pick fails' '
+       pristine_detach initial &&
+
+       test_must_fail git cherry-pick picked &&
+       echo resolved >foo &&
+       git add foo &&
+       test_must_fail git commit --amend 2>err &&
+
+       test_i18ngrep "in the middle of a cherry-pick -- cannot amend." err
+'
+
 test_expect_success 'successful final commit clears cherry-pick state' '
        pristine_detach initial &&