From: Junio C Hamano Date: Sat, 15 Mar 2008 04:54:45 GMT Subject: Re: Fix recent 'unpack_trees()'-related changes breaking 'git stash' Message-ID: <7v1w6cpox6.fsf@gitster.siamese.dyndns.org> In-Reply-To: Linus Torvalds writes: > Damn, this series has had more subtle issues than I ever expected. > > 'git stash' creates its saved working tree object with: > > # 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 && > git read-tree -m $i_tree && > git add -u && > git write-tree && > rm -f "$TMP-index" > ) ) || > die "Cannot save the current worktree state" > > which creates a new index file with the updates, and writes the tree from > that. It would be slightly simpler to write the above sequence like this: w_tree=$( ( rm -f "$TMP-index" && git read-tree --index-output="$TMP-index" -m $i_tree && GIT_INDEX_FILE="$TMP-index" && export GIT_INDEX_FILE && git add -u && git write-tree && rm -f "$TMP-index" ) ) I think your fix would apply equally well if we rewrite stash to work like this.