git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: しらいしななこ <nanako3@bluebottle.com>, GIT <git@vger.kernel.org>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] Document git-stash
Date: Sun, 01 Jul 2007 14:39:56 -0700	[thread overview]
Message-ID: <7vps3b4xcj.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <20070701091905.GA13559@coredump.intra.peff.net> (Jeff King's message of "Sun, 1 Jul 2007 05:19:05 -0400")

Jeff King <peff@peff.net> writes:

> On Sun, Jul 01, 2007 at 06:06:29PM +0900, しらいしななこ wrote:
>
>> I don't understand myself anymore, either (^_^;) I just tried to follow
>> Jnio's earlier suggestion in his message.  He said this.
>
> OK, we will wait for Junio to clarify tomorrow. :)

Jeez.  I tried to stay lazy and have all the work done by
somebody else (and taking the credit at the end, as I was
mentored by you-know-who ;-), but you guys managed to suck me
into this.

There are a few issues when you replay a stash on a state that
is different from the state the stash was created on.

Stash records the then-current HEAD, index and the working tree
(I'll call them H, I and W for brevity from now on).  Ideally,
we would want to have the difference between the resulting index
and working tree to be similar to the difference between I and
W.

Replaying the stash is done on a clean working tree.  That is,
we require that at least the index and working tree match (we
could also require that the index and HEAD match, but I do not
think it changes anything in this discussion).  And we apply the
change between H and W with three-way merge.

For paths that are cleanly merged with this three-way merge,
merge-recursive updates the working tree and the index.  That
means if you do "git diff", you would not see the local changes
that were carried forward would not be visible, and you would
need "git diff HEAD" to view them.  I found it confusing, and
that was the suggestion I sent was about.  Nana's "3rd try", which
I applied and pushed to 'next', addresses this issue by running
"read-tree --reset $c_tree" (where $c_tree is the contents of
the index before replaying the stash).

This is not ideal.  We would want to see "git diff" for such a
path show difference similar to difference between I and W.

There is a little glitch, though.  Such an operation can also be
done with a three-way merge (git-merge-file would most likely be
useful), but what would we do when this second merge conflicts?
If we insist on making the "git diff" output to match the diff
between I and W for the path, somebody needs to resolve the
conflict and put the result in the index, but if git-merge-file
couldn't, the user is left to do that.  I strongly suspect that
we would not want that aggravation (besides, the working tree
cannot be used anymore as it contains what we would want to
leave there as the result of unstashing).  The second best thing
is probably to leave the index as it was before the stash was
applied for such a path (in other words, for such a path, we
discard the difference between I and W, favoring to use W).

We could still attempt to carry the difference between I and W
for paths that the second merge cleanly resolves, but then "git
diff" will show full diff between H and W for some paths (that
is, the ones the second merge did not cleanly resolve) while
diff between I and W for others (the ones that resolved
cleanly).  That is not what the current code does, though.

I am hoping that the "best effort" would make it more convenient
to use, but I also suspect that it might make things more
confusing to the end user and certainly more difficult to explain.

So that's about the cleanly-merged case.

What we should do about the paths that the first merge (i.e. the
one that updates the working tree) does not resolve cleanly?  We
would want to keep the index the way merge-recursive left, for
conflicting paths at least.  We would have higher stages for
them, so that the user will not accidentally commit things that
have not been merged, and can use usual conflict resolution
techniques like "git diff" to view the combined diff between
three versions.

  reply	other threads:[~2007-07-01 21:40 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-30  1:29 [PATCH (2nd try)] Add git-stash script しらいしななこ
2007-06-30  2:05 ` Johannes Schindelin
2007-06-30  5:37   ` [PATCH (3rd " しらいしななこ
2007-06-30  6:12     ` Jeff King
2007-06-30  6:25       ` Junio C Hamano
2007-06-30 15:41     ` Johannes Schindelin
2007-06-30 17:19       ` Junio C Hamano
2007-06-30 23:27       ` しらいしななこ
2007-06-30 15:44     ` [PATCH] Add a manual page for git-stash Johannes Schindelin
2007-06-30 16:38       ` Frank Lichtenheld
2007-06-30 17:48         ` Johannes Schindelin
2007-06-30 18:45           ` Frank Lichtenheld
2007-06-30 17:44       ` Junio C Hamano
2007-06-30 17:56         ` Johannes Schindelin
2007-06-30 18:13           ` Junio C Hamano
2007-06-30 18:44             ` Johannes Schindelin
2007-07-01  5:26           ` [PATCH] Document git-stash しらいしななこ
2007-07-01  6:48             ` Junio C Hamano
2007-07-01  8:07             ` Jeff King
2007-07-01  8:38               ` Junio C Hamano
2007-07-01  9:06               ` しらいしななこ
     [not found]               ` <200707010910.l619A23c027837@mi0.bluebottle.com>
2007-07-01  9:19                 ` Jeff King
2007-07-01 21:39                   ` Junio C Hamano [this message]
2007-07-02  4:08                     ` Jeff King
2007-07-01 21:54               ` Junio C Hamano
2007-07-01 22:57                 ` Johannes Schindelin
2007-07-02  4:10                 ` Jeff King
2007-07-02 10:33                   ` Johannes Schindelin
2007-07-02 10:44                     ` [PATCH] git-stash: Make "save" the default operation again Johannes Schindelin
2007-07-02 11:00                       ` Jeff King
2007-07-02 11:15                         ` Johannes Schindelin
2007-07-02 23:11                           ` Junio C Hamano
2007-07-01  5:20       ` [PATCH] Add a manual page for git-stash Junio C Hamano
2007-06-30 16:06     ` [PATCH] Add tests " Johannes Schindelin

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=7vps3b4xcj.fsf@assigned-by-dhcp.cox.net \
    --to=gitster@pobox.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=nanako3@bluebottle.com \
    --cc=peff@peff.net \
    /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).