diff options
author | Matthias Aßhauer <mha1993@live.de> | 2016-01-28 20:36:05 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-01-29 11:13:15 -0800 |
commit | 5390c28c0ba1b450f78d7be2e19eb05a8bd81cf2 (patch) | |
tree | 2c7f7d6840ff23cfc06c80c121c1cfd5414624ad | |
parent | f2440f1efa34cbfe5d06f1d7c57861ac3d5bc0e6 (diff) | |
download | git-ma/stash-in-c.tar.gz |
stash: use "stash--helper"ma/stash-in-c
Use the new "git stash--helper" builtin. It should be faster than
the old shell code and is a first step to move more shell code to C.
[jc: Thomas Gummerer <t.gummerer@gmail.com> gave an addition to perf]
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-x | git-stash.sh | 10 | ||||
-rwxr-xr-x | t/perf/p3000-stash.sh | 20 |
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 |