Skip to content

Commit b04e691

Browse files
klusarkgitster
authored andcommitted
stash: add a test for when apply fails during stash branch
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c95bc22 commit b04e691

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/t3903-stash.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,20 @@ test_expect_success 'stash branch should not drop the stash if the branch exists
656656
git rev-parse stash@{0} --
657657
'
658658

659+
test_expect_success 'stash branch should not drop the stash if the apply fails' '
660+
git stash clear &&
661+
git reset HEAD~1 --hard &&
662+
echo foo >file &&
663+
git add file &&
664+
git commit -m initial &&
665+
echo bar >file &&
666+
git stash &&
667+
echo baz >file &&
668+
test_when_finished "git checkout master" &&
669+
test_must_fail git stash branch new_branch stash@{0} &&
670+
git rev-parse stash@{0} --
671+
'
672+
659673
test_expect_success 'stash apply shows status same as git status (relative to current directory)' '
660674
git stash clear &&
661675
echo 1 >subdir/subfile1 &&

0 commit comments

Comments
 (0)