@matheusbsbs / matheus-bagliano / commits / 835d6a1f9f
Fork 0

stash drops the stash even if creating the branch fails because it already exists

This bug was disovered by someone on IRC when he tried to $ git stash branch <branch> <stash> while <branch> already existed. In that case the stash is dropped even though it isn't applied on any branch, so the stash is effectively lost. Signed-off-by: Tomas Carnecky <tom@dbservice.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Tomas Carnecky committed Sep 28, 2010 at 23:19 UTC 835d6a1f9f6f0f6e47cf32238af7ee8b8d048d78
1 file changed +11
t/t3903-stash.sh
+11
@@ -545,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
545 git stash drop
546 '
547
548 +test_expect_failure 'stash branch should not drop the stash if the branch exists' '
549 + git stash clear &&
550 + echo foo >file &&
551 + git add file &&
552 + git commit -m initial &&
553 + echo bar >file &&
554 + git stash &&
555 + test_must_fail git stash branch master stash@{0} &&
556 + git rev-parse stash@{0} --
557 +'
558 +
559 test_done