git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Frans Klaver <fransklaver@gmail.com>,
	git@vger.kernel.org, "Horst H. von Brand" <vonbrand@inf.utfsm.cl>,
	Conrad Irwin <conrad.irwin@gmail.com>
Subject: Re: git 1.8.0.rc0.18.gf84667d trouble with "git commit -p file"
Date: Sat, 6 Oct 2012 09:12:00 -0400	[thread overview]
Message-ID: <20121006131200.GB11712@sigill.intra.peff.net> (raw)
In-Reply-To: <7v8vbkru8o.fsf@alter.siamese.dyndns.org>

On Fri, Oct 05, 2012 at 11:26:47PM -0700, Junio C Hamano wrote:

> In the case of "add/commit --interactive", it is much more clear
> what state the index is in when the command gave interactive control
> to the user.  The short-cut "add/commit -p" interface, however, does
> not give you an access to its s)tatus subcommand, making the user
> experience somewhat different.
> 
> That makes the problem much more severe for "-p" compared to
> "--interactive", but the fundamental UI consistency it introduces is
> the same as the issue under discussion in this thread.

Agreed.

> Suppose you have two paths E and F, both of which have differences
> between HEAD and the index, and the index and the working tree file
> (i.e. you earlier edited E and F, did "git add E F" and further
> edited them).
> 
> You say "git commit -p F".
> 
> What should happen?  It is clear that the resulting commit should
> record no change since its parent commit at path E (that is what
> "only" semantics mean).
> 
> What state should the "add -p" interaction start from for path F?
> Should you be picking from a patch between the state you previously
> "git add"ed to the index and the working tree, or should the entire
> difference between HEAD and the working tree eligible to be picked
> or deferred during the "add -p" session?  Starting from a temporary
> index that matches HEAD essentially means that you lose the earlier
> "git add F" [*1*].
> 
> Another case to consider is to start from the same condition, and
> instead to say "git commit -p" without any pathspec.  What should
> happen?

Hmm. Good questions. In the former case, I would have said you should
definitely omit E and then start from the staged point of F, as that is
almost certainly what the user meant. But that is utterly inconsistent
with what we are discussing for the no-pathspec case.

I have a gut feeling that what I would expect for "-p" is roughly:

  1. Feed add--interactive the current index state.

  2. Feed add--interactive the set of pathspecs on the command line to
     limit its work.

  3. For any path that is updated by the interactive session, keep the
     result.

  4. For other paths, revert to HEAD.

I think that would "do what I mean" most of the time. But it is a
horrible set of rules to try to explain to someone (and it is off the
top of my head; I wouldn't be surprised if you can come up with a
situation where those rules do not behave well).

> Just doing "use a temporary index that is initialized to HEAD" may
> be an expedient thing to do, but I suspect that I will be saying the
> same "I should have said 'You cannot have a pony' back then" again
> in a not so distant future if we did so without thinking these
> things through.
> 
> As I do not see any practical value in "commit -p", I do not think
> it is worth my time thinking these things through thoroughly myself.
> 
> Unless somebody who cares about "commit -p" does so to come up with
> reasonable semantics, and updates the code to match that desired
> behaviour, the responsible thing to do is to error out "-p" when
> your index is different from HEAD, I think.

Yeah. I did not agree with your conclusion here when we started the
conversation, but I am starting to now. I am not opposed at all to
somebody working out the semantics, but I do not really care to work on
it myself. In the meantime, I would rather not do any halfway fixes
that will just make things worse.

Another option is to leave it with "-i" semantics in the meantime, which
are at least easy to explain: it is simply a shorthand for running "git
add -p && git commit". That may be inconsistent with other aspects of
commit, but people have (apparently) been happy with it, and there has
not been a rash of complaints.

As a non-user of "commit -p" myself, I don't have a strong opinion
either way.

-Peff

  reply	other threads:[~2012-10-06 13:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-05 14:20 git 1.8.0.rc0.18.gf84667d trouble with "git commit -p file" Horst H. von Brand
2012-10-05 19:55 ` Frans Klaver
2012-10-05 22:29   ` Junio C Hamano
2012-10-05 22:57     ` Jeff King
2012-10-06  6:26       ` Junio C Hamano
2012-10-06 13:12         ` Jeff King [this message]
2012-10-06 18:22           ` Junio C Hamano
2012-10-06 18:30             ` Jeff King
2012-10-06 18:32               ` Conrad Irwin
2012-10-06 19:07                 ` Jeff King
2012-10-07 20:51                   ` Junio C Hamano
2012-10-07 21:49                     ` Jeff King
2012-10-07 22:23                       ` Junio C Hamano
2012-10-07 22:25                         ` Jeff King
2012-10-11  5:51                           ` Conrad Irwin
2012-10-11 17:57                             ` Junio C Hamano

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=20121006131200.GB11712@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=conrad.irwin@gmail.com \
    --cc=fransklaver@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=vonbrand@inf.utfsm.cl \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).