From 5390c28c0ba1b450f78d7be2e19eb05a8bd81cf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20A=C3=9Fhauer?= Date: Thu, 28 Jan 2016 20:36:05 +0000 Subject: stash: use "stash--helper" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 gave an addition to perf] Signed-off-by: Matthias Aßhauer Signed-off-by: Junio C Hamano --- git-stash.sh | 10 +--------- t/perf/p3000-stash.sh | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 9 deletions(-) create mode 100755 t/perf/p3000-stash.sh 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 -- cgit v1.2.1