summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgit-stash.sh10
-rwxr-xr-xt/perf/p3000-stash.sh20
2 files changed, 21 insertions, 9 deletions
diff --git a/git-stash.sh b/git-stash.sh
index c7c65e25f5..973c77bddb 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -112,15 +112,7 @@ create_stash () {
then
# state of the working tree
- w_tree=$( (
- git read-tree --index-output="$TMPindex" -m $i_tree &&
- GIT_INDEX_FILE="$TMPindex" &&
- export GIT_INDEX_FILE &&
- git diff --name-only -z HEAD -- >"$TMP-stagenames" &&
- git update-index -z --add --remove --stdin <"$TMP-stagenames" &&
- git write-tree &&
- rm -f "$TMPindex"
- ) ) ||
+ w_tree=$(git stash--helper --non-patch "$TMPindex" $i_tree) ||
die "$(gettext "Cannot save the current worktree state")"
else
diff --git a/t/perf/p3000-stash.sh b/t/perf/p3000-stash.sh
new file mode 100755
index 0000000000..4b1b0ee011
--- /dev/null
+++ b/t/perf/p3000-stash.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+test_description="Test performance of git stash"
+
+. ./perf-lib.sh
+
+test_perf_default_repo
+
+file=$(git ls-files | tail -n 30 | head -n 1)
+
+test_expect_success "prepare repository" "
+ echo x >$file
+"
+
+test_perf "stash/stash pop" "
+ git stash &&
+ git stash pop
+"
+
+test_done