checkout-index: fix --temp relative path mangling
[gitweb.git] / git-stash.sh
index f0a94abf1434c65d27caf4cd674f89de62e9333c..4621d81fab472310e1183c1b9914644259a911e8 100755 (executable)
@@ -94,7 +94,8 @@ create_stash () {
                # ease of unpacking later.
                u_commit=$(
                        untracked_files | (
-                               export GIT_INDEX_FILE="$TMPindex"
+                               GIT_INDEX_FILE="$TMPindex" &&
+                               export GIT_INDEX_FILE &&
                                rm -f "$TMPindex" &&
                                git update-index -z --add --remove --stdin &&
                                u_tree=$(git write-tree) &&
@@ -512,8 +513,14 @@ apply_stash () {
 pop_stash() {
        assert_stash_ref "$@"
 
-       apply_stash "$@" &&
-       drop_stash "$@"
+       if apply_stash "$@"
+       then
+               drop_stash "$@"
+       else
+               status=$?
+               say "The stash is kept in case you need it again."
+               exit $status
+       fi
 }
 
 drop_stash () {