stash: fix git stash branch regression when branch creation fails
[gitweb.git] / git-stash.sh
index 57f36ce8dd7cd25e269f8e31d6fdc668d62811f9..02113263e3d84b49aae8d2961a53c598c797584d 100755 (executable)
@@ -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'