Skip to content

Commit

Permalink
stash drops the stash even if creating the branch fails because it al…
Browse files Browse the repository at this point in the history
…ready 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>
  • Loading branch information
Tomas Carnecky authored and Junio C Hamano committed Sep 29, 2010
1 parent 442cb08 commit 835d6a1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions t/t3903-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -545,4 +545,15 @@ test_expect_success 'invalid ref of the form stash@{n}, n >= N' '
git stash drop
'

test_expect_failure 'stash branch should not drop the stash if the branch exists' '
git stash clear &&
echo foo >file &&
git add file &&
git commit -m initial &&
echo bar >file &&
git stash &&
test_must_fail git stash branch master stash@{0} &&
git rev-parse stash@{0} --
'

test_done

0 comments on commit 835d6a1

Please sign in to comment.