stash: fix git stash branch regression when branch creation fails
"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>
diff --git a/git-stash.sh b/git-stash.sh
index 57f36ce..0211326 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -446,9 +446,9 @@
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'
diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
index 4215cc6..903a122 100755
--- a/t/t3903-stash.sh
+++ b/t/t3903-stash.sh
@@ -545,7 +545,7 @@
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 &&