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>
Jon Seymour committed
Sep 28, 2010 at 23:19 UTC
57693d03db93959831c9c017953f979aae6cc8eb
2 files changed
+4
-4
git-stash.sh
+3
-3
@@ -446,9 +446,9 @@ apply_to_branch () {
446
assert_stash_like "$@"
447
448
git checkout -b $branch $REV^ &&
449
- apply_stash "$@"
450
-
451
- test -z "$IS_STASH_REF" || drop_stash "$@"
449
+ apply_stash "$@" && {
450
+ test -z "$IS_STASH_REF" || drop_stash "$@"
451
+ }
452
}
453
454
PARSE_CACHE='--not-parsed'
t/t3903-stash.sh
+1
-1
@@ -545,7 +545,7 @@ 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' '
548
+test_expect_success 'stash branch should not drop the stash if the branch exists' '
549
git stash clear &&
550
echo foo >file &&
551
git add file &&