git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: SZEDER G?bor <szeder@ira.uka.de>, Git Mailing List <git@vger.kernel.org>
Subject: Re: Fix recent 'unpack_trees()'-related changes breaking 'git stash'
Date: Fri, 14 Mar 2008 21:54:45 -0700	[thread overview]
Message-ID: <7v1w6cpox6.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LFD.1.00.0803142023490.3557@woody.linux-foundation.org> (Linus Torvalds's message of "Fri, 14 Mar 2008 21:20:41 -0700 (PDT)")

Linus Torvalds <torvalds@linux-foundation.org> 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.

  parent reply	other threads:[~2008-03-15  4:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-15  1:41 recent 'unpack_trees()'-related changes break 'git stash' SZEDER Gábor
2008-03-15  4:20 ` Fix recent 'unpack_trees()'-related changes breaking " Linus Torvalds
2008-03-15  4:40   ` Linus Torvalds
2008-03-15 11:31     ` Szeder Gábor
2008-03-15  4:54   ` Junio C Hamano [this message]
2008-03-15 11:36     ` Szeder Gábor
2008-03-15 16:51     ` Linus Torvalds
2008-03-30 21:14       ` [PATCH] git-stash: use git-read-tree --index-output option しらいしななこ

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v1w6cpox6.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=szeder@ira.uka.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).