]> git.ipfire.org Git - thirdparty/git.git/commitdiff
git-stash: try reusing cached stat info as much as possible
authorJunio C Hamano <gitster@pobox.com>
Sun, 8 Jul 2007 08:28:18 +0000 (01:28 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Jul 2007 01:24:18 +0000 (18:24 -0700)
Earlier when we read a tree into a temporary index, we read it
from scratch.  Start from the current index and use read-tree -m
to preserve cached stat information as much as possible, in
order to speed up "git add -u".  This makes "git stash" usable
in a source tree of nontrivial size.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-stash.sh

index eac5551380539e629c07e3f6afece9b5e2d16c0a..de13dd1812170ca76eb5706aefb7f59d22be6d48 100755 (executable)
@@ -58,11 +58,11 @@ save_stash () {
 
        # state of the working tree
        w_tree=$( (
+               rm -f "$TMP-index" &&
+               cp -p ${GIT_INDEX_FILE-"$GIT_DIR/index"} "$TMP-index" &&
                GIT_INDEX_FILE="$TMP-index" &&
                export GIT_INDEX_FILE &&
-
-               rm -f "$TMP-index" &&
-               git read-tree $i_tree &&
+               git read-tree -m $i_tree &&
                git add -u &&
                git write-tree &&
                rm -f "$TMP-index"