Skip to content

Commit bf87e09

Browse files
committed
Merge branch 'js/maint-stash-index-copy' into maint
* js/maint-stash-index-copy: stash: copy the index using --index-output instead of cp -p stash: fix incorrect quoting in cleanup of temporary files
2 parents b7f6afe + 3ba2e86 commit bf87e09

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

git-stash.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ require_work_tree
1717
cd_to_toplevel
1818

1919
TMP="$GIT_DIR/.git-stash.$$"
20-
trap 'rm -f "$TMP-*"' 0
20+
TMPindex=${GIT_INDEX_FILE-"$GIT_DIR/index"}.stash.$$
21+
trap 'rm -f "$TMP-"* "$TMPindex"' 0
2122

2223
ref_stash=refs/stash
2324

@@ -81,14 +82,12 @@ create_stash () {
8182

8283
# state of the working tree
8384
w_tree=$( (
84-
rm -f "$TMP-index" &&
85-
cp -p ${GIT_INDEX_FILE-"$GIT_DIR/index"} "$TMP-index" &&
86-
GIT_INDEX_FILE="$TMP-index" &&
85+
git read-tree --index-output="$TMPindex" -m $i_tree &&
86+
GIT_INDEX_FILE="$TMPindex" &&
8787
export GIT_INDEX_FILE &&
88-
git read-tree -m $i_tree &&
8988
git diff --name-only -z HEAD | git update-index -z --add --remove --stdin &&
9089
git write-tree &&
91-
rm -f "$TMP-index"
90+
rm -f "$TMPindex"
9291
) ) ||
9392
die "Cannot save the current worktree state"
9493

0 commit comments

Comments
 (0)