threads / patch / 8930

patchgit-stash: try reusing cached stat info as much as possible

Subject: [PATCH] git-stash: try reusing cached stat info as much as possible

## tl;dr

One message between Jul 8, 2007 and Jul 8, 2007. Diffs are folded; open one to read it.

replies: 0people: 1as markdown or json

Junio C Hamano· Jul 8, 2007, 18:43 UTC · lore

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 |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Show changes to git-stash.sh +3 −3
diff --git a/git-stash.sh b/git-stash.sh
index eac5551..de13dd1 100755
--- a/git-stash.sh
+++ b/git-stash.sh
@@ -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"
-- 
1.5.3.rc0.858.gd08b

← back to recent threads