stash: add a test for when apply fails during stash branch
authorJoel Teichroeb <joel@teichroeb.net>
Sat, 19 Aug 2017 20:13:25 +0000 (13:13 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 19 Aug 2017 21:03:56 +0000 (14:03 -0700)
If the return value of merge recursive is not checked, the stash could end
up being dropped even though it was not applied properly

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t3903-stash.sh
index f0708ced276381a7694553a8767d696201cf5149..887010c4978f5dbed700e0daabed67fa827fc045 100755 (executable)
@@ -656,6 +656,20 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
        git rev-parse stash@{0} --
 '
 
+test_expect_success 'stash branch should not drop the stash if the apply fails' '
+       git stash clear &&
+       git reset HEAD~1 --hard &&
+       echo foo >file &&
+       git add file &&
+       git commit -m initial &&
+       echo bar >file &&
+       git stash &&
+       echo baz >file &&
+       test_when_finished "git checkout master" &&
+       test_must_fail git stash branch new_branch stash@{0} &&
+       git rev-parse stash@{0} --
+'
+
 test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
        git stash clear &&
        echo 1 >subdir/subfile1 &&