From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Thomas Rast <trast@student.ethz.ch>,
git@vger.kernel.org, Sverre Rabbelier <srabbelier@gmail.com>,
Nanako Shiraishi <nanako3@lavabit.com>,
Nicolas Sebrecht <nicolas.s.dev@gmx.fr>,
Pierre Habouzit <madcoder@debian.org>
Subject: Re: [PATCH v5 0/6] {checkout,reset,stash} --patch
Date: Sat, 15 Aug 2009 00:57:06 -0700 [thread overview]
Message-ID: <7v4os9v7al.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20090815065125.GA23068@coredump.intra.peff.net> (Jeff King's message of "Sat\, 15 Aug 2009 02\:51\:26 -0400")
Jeff King <peff@peff.net> writes:
>> reset -p [HEAD] Reset this hunk? (**)
>> reset -p other Apply this hunk to index? (**)
>
> This doesn't make sense to me.
Not to me, either.
Let's say you have modified $path and ran "git add $path" earlier.
"reset -p -- $path" and "reset -p HEAD -- $path" both show what your index
has relative to the commit you are resetting your index to and offer to
"Unstage" [*1*]. This is consistent and feels natural.
"reset -p HEAD^ -- $path" however shows the same forward diff (i.e. how
your index is different compared to the commit HEAD^ you are resetting
to), but offers to "Apply".
When a user is resetting to the current HEAD (with or without an explicit
HEAD parameter), it is likely that the user did "git add" earlier and is
trying to reverse the effect of that. And showing a forward diff makes
sense. But when a user is resetting to a different commit, it may make
sense to show a reverse diff, saying "Here is a hunk you _could_ choose to
use to bring the current index to a different state, do you want to apply
it to do so?" Perhaps you meant to show a reverse diff and use the word
"Apply".
However, that would break down rather badly when HEAD did not change $path
since HEAD^. Logically what the "reset -p" would do to $path is the same,
but the patch shown and the operation offered to the user are opposite.
You could compare HEAD and the commit you are resetting the index to and
see if the path in question is different between the two commits, and
switch the direction---if there is no change, you show forward diff and
offer to "Remove this change out of the index", if there is a change, you
show reverse diff and offer to "Apply this change to the index". But if
the difference between HEAD and the commit you are resetting to does not
overlap with the change you staged to the index earlier from your work
tree, it is unclear such heuristics would yield a natural feel.
So I actually think you may be better off if you consistently showed a
forward diff (i.e. what patch would have been applied to the commit in
question to bring the index into its current shape), and always offer
"Remove this change out of the index?"
The same comment applies to "checkout -p HEAD" vs "checkout -p HEAD^".
I think the latter shouldn't show a reverse diff and offer "Apply?";
instead both should consitently show a forward diff (i.e. what patch would
have been applied to the commit to bring your work tree into its current
shape), and offer "Remove this change out of the index and the work tree?".
[Footnote]
*1* I actually have a slight problem with the use of word "Unstage" in
this context; "to stage", at least to me, means "adding _from the work
tree_ to the index", not just "modifying the index" from a random source.
The command is resetting the index in this case from a tree-ish and there
is no work tree involved, and the word "stage/unstage" feels out of place.
next prev parent reply other threads:[~2009-08-15 8:00 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-23 7:41 [PATCH] git-add -p: be able to undo a given hunk Pierre Habouzit
2009-07-23 8:41 ` Thomas Rast
2009-07-23 8:50 ` Pierre Habouzit
2009-07-24 9:15 ` [RFC PATCH] Implement unstage and reset modes for git-add--interactive Thomas Rast
2009-07-24 16:24 ` [RFC PATCH v2 1/3] Introduce git-unstage Thomas Rast
2009-07-24 17:59 ` Bert Wesarg
2009-07-24 18:02 ` Bert Wesarg
2009-07-24 18:23 ` Elijah Newren
2009-07-24 16:24 ` [RFC PATCH v2 2/3] Introduce git-discard Thomas Rast
2009-07-24 18:02 ` Elijah Newren
2009-07-24 18:12 ` Bert Wesarg
2009-07-24 18:24 ` Elijah Newren
2009-07-25 14:58 ` Pierre Habouzit
2009-07-24 16:24 ` [RFC PATCH v2 3/3] Implement unstage --patch and discard --patch Thomas Rast
2009-07-24 16:40 ` Matthias Kestenholz
2009-07-24 18:08 ` Bert Wesarg
2009-07-24 16:39 ` [RFC PATCH] Implement unstage and reset modes for git-add--interactive Junio C Hamano
2009-07-24 21:58 ` Nanako Shiraishi
2009-07-24 23:17 ` Thomas Rast
2009-07-24 23:25 ` Junio C Hamano
2009-07-25 21:29 ` [RFC PATCH v3 0/5] {checkout,reset,stash} --patch Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 1/5] git-apply--interactive: Refactor patch mode code Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 2/5] builtin-add: refactor the meat of interactive_add() Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 3/5] Implement 'git reset --patch' Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 4/5] Implement 'git checkout --patch' Thomas Rast
2009-07-25 21:29 ` [RFC PATCH v3 5/5] Implement 'git stash save --patch' Thomas Rast
2009-07-26 6:03 ` Sverre Rabbelier
2009-07-26 8:45 ` Thomas Rast
2009-07-27 10:10 ` [RFC PATCH v3 0/5] {checkout,reset,stash} --patch Thomas Rast
2009-07-28 21:20 ` [PATCH v4 " Thomas Rast
2009-07-28 21:20 ` [PATCH v4 1/5] git-apply--interactive: Refactor patch mode code Thomas Rast
2009-07-28 21:20 ` [PATCH v4 2/5] builtin-add: refactor the meat of interactive_add() Thomas Rast
2009-07-28 21:20 ` [PATCH v4 3/5] Implement 'git reset --patch' Thomas Rast
2009-07-28 21:20 ` [PATCH v4 4/5] Implement 'git checkout --patch' Thomas Rast
2009-07-28 21:20 ` [PATCH v4 5/5] Implement 'git stash save --patch' Thomas Rast
2009-07-28 21:20 ` [PATCH v4 6/5] DWIM 'git stash save -p' for 'git stash -p' Thomas Rast
2009-08-09 6:52 ` [PATCH v4 0/5] {checkout,reset,stash} --patch Jeff King
2009-08-09 9:17 ` Thomas Rast
2009-08-09 16:32 ` [PATCH v4 0/5] " Nicolas Sebrecht
2009-08-09 16:44 ` Thomas Rast
2009-08-09 21:28 ` Nicolas Sebrecht
2009-08-09 21:42 ` Thomas Rast
2009-08-09 22:26 ` Nicolas Sebrecht
2009-08-10 9:36 ` Thomas Rast
2009-08-13 12:29 ` [PATCH v5 0/6] " Thomas Rast
2009-08-13 12:29 ` [PATCH v5 1/6] git-apply--interactive: Refactor patch mode code Thomas Rast
2009-08-13 12:29 ` [PATCH v5 2/6] Add a small patch-mode testing library Thomas Rast
2009-08-13 12:29 ` [PATCH v5 3/6] builtin-add: refactor the meat of interactive_add() Thomas Rast
2009-08-13 12:29 ` [PATCH v5 4/6] Implement 'git reset --patch' Thomas Rast
2009-08-15 11:48 ` [PATCH v5.1 " Thomas Rast
2009-08-13 12:29 ` [PATCH v5 5/6] Implement 'git checkout --patch' Thomas Rast
2009-08-15 11:48 ` [PATCH v5.1 " Thomas Rast
2009-08-13 12:29 ` [PATCH v5 6/6] Implement 'git stash save --patch' Thomas Rast
2009-08-13 12:29 ` [PATCH v5 7/6] DWIM 'git stash save -p' for 'git stash -p' Thomas Rast
2009-08-14 20:57 ` [PATCH v5 0/6] Re: {checkout,reset,stash} --patch Nicolas Sebrecht
2009-08-15 6:51 ` [PATCH v5 0/6] " Jeff King
2009-08-15 7:57 ` Junio C Hamano [this message]
2009-08-15 10:14 ` Thomas Rast
2009-08-15 10:04 ` Thomas Rast
2009-08-18 16:48 ` Jeff King
2009-08-19 9:40 ` Thomas Rast
2009-08-19 10:11 ` Jeff King
2009-07-23 19:58 ` [PATCH] git-add -p: be able to undo a given hunk Junio C Hamano
2009-07-24 10:32 ` Nanako Shiraishi
2009-07-24 16:06 ` Junio C Hamano
2009-07-24 17:06 ` Jeff King
2009-07-25 0:54 ` Junio C Hamano
2009-07-25 9:35 ` Thomas Rast
2009-07-25 14:48 ` Pierre Habouzit
2009-07-25 14:52 ` Pierre Habouzit
2009-07-26 15:39 ` Jeff King
2009-07-27 8:26 ` Pierre Habouzit
2009-07-27 10:30 ` Jeff King
2009-07-27 10:06 ` Thomas Rast
2009-07-27 10:36 ` Jeff King
2009-07-24 14:58 ` Pierre Habouzit
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=7v4os9v7al.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=madcoder@debian.org \
--cc=nanako3@lavabit.com \
--cc=nicolas.s.dev@gmx.fr \
--cc=peff@peff.net \
--cc=srabbelier@gmail.com \
--cc=trast@student.ethz.ch \
/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).