Skip to content

Commit

Permalink
stash: fix git stash branch regression when branch creation fails
Browse files Browse the repository at this point in the history
"git stash branch <branch> <stash>" started discarding the stash
when the branch creation fails.  It should have kept the stash
intact when aborting.

Signed-off-by: Jon Seymour <jon.seymour@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jon Seymour authored and Junio C Hamano committed Sep 29, 2010
1 parent 835d6a1 commit 57693d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions git-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,9 @@ apply_to_branch () {
assert_stash_like "$@"

git checkout -b $branch $REV^ &&
apply_stash "$@"

test -z "$IS_STASH_REF" || drop_stash "$@"
apply_stash "$@" && {
test -z "$IS_STASH_REF" || drop_stash "$@"
}
}

PARSE_CACHE='--not-parsed'
Expand Down
2 changes: 1 addition & 1 deletion t/t3903-stash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ 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' '
test_expect_success 'stash branch should not drop the stash if the branch exists' '
git stash clear &&
echo foo >file &&
git add file &&
Expand Down

0 comments on commit 57693d0

Please sign in to comment.