Re: Fix recent 'unpack_trees()'-related changes breaking 'git stash'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 15, 2008, 04:54 UTC
- Message-ID
- <7v1w6cpox6.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <alpine.LFD.1.00.0803142023490.3557@woody.linux-foundation.org>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 19 quoted lines
> 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.