git.vger.kernel.org archive mirror
 help / color / mirror / 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: Fri, 5 Oct 2012 18:57:58 -0400	[thread overview]
Message-ID: <20121005225758.GA1202@sigill.intra.peff.net> (raw)
In-Reply-To: <7vsj9ssgcp.fsf@alter.siamese.dyndns.org>

On Fri, Oct 05, 2012 at 03:29:10PM -0700, Junio C Hamano wrote:

> Assuming that the last step of what Horst did was "git commit -pm",
> I think Git is wrong in this case.  When you tell "git commit" what
> to commit, unless you give "-i" (aka "also") option, the command
> makes a commit to record changes only from what you tell "git
> commit" to commit, regardless of what you earlier did to the index.

Yeah. Defaulting to "-o" would match the rest of git-commit's behavior
much better.

> This is one of the times I wish I said "No, you cannot have a pony".
> The change was done without thinking things through, and reviewers
> including me did not realize this particular downside.
> [...]
> Cf. 
> 
>   http://thread.gmane.org/gmane.comp.version-control.git/173033/focus=173246

Actually, I am not sure that thread or feature is to blame. Certainly it
would have been an opportune time to notice the problem. But this issue
goes back much further for "git commit --interactive", which has always
assumed "-i" rather than "-o". This even predates the switch from shell
to C; you can see the same behavior from 6cbf07e (git-commit: add a
--interactive option, 2007-03-05).

I guess you could argue that "--interactive" and "--patch" should have
different defaults, but I'm not sure I agree. They should both match
what "git commit foo" does by default.

> I think the right thing to do is to fix "git commit -p" so that it
> starts from the HEAD (on a temporary index), just like how partial
> commits are made with "git commit file1 file2".   Or just forbid it
> when the index does not match HEAD.

Agreed. I am inclined to call this a bugfix, though it does worry me
slightly that we would be changing a behavior that has existed for so
many years.

We should probably also support explicit "-i -p" and "-o -p" options, as
well (the former would give people who really want the existing behavior
a way to get it). And the same for "--interactive". I can't say I'm
excited about making all that work, though. Like you, I think it is more
sane to use existing tools to inspect and tweak the index to your
liking, and then commit.

-Peff

  reply	other threads:[~2012-10-05 22:58 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 [this message]
2012-10-06  6:26       ` Junio C Hamano
2012-10-06 13:12         ` Jeff King
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

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

  git send-email \
    --in-reply-to=20121005225758.GA1202@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.
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).