Re: Fix recent 'unpack_trees()'-related changes breaking 'git stash'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> 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.
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux