git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: git 1.8.0.rc0.18.gf84667d trouble with "git commit -p file"

From
Jeff King <peff@peff.net>
Date
Oct 5, 2012, 22:57 UTC
Message-ID
<20121005225758.GA1202@sigill.intra.peff.net>
In-Reply-To
<7vsj9ssgcp.fsf@alter.siamese.dyndns.org>
On Fri, Oct 05, 2012 at 03:29:10PM -0700, Junio C Hamano wrote:
Show 5 quoted lines
> 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.

Show 7 quoted lines
> 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
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 16 in “git 1.8.0.rc0.18.gf84667d trouble with "git commit -p file"”
  1. Horst H. von BrandOct 5, 2012
  2. Frans KlaverOct 5, 2012
  3. Junio C HamanoOct 5, 2012
  4. Jeff KingOct 5, 2012
  5. Junio C HamanoOct 6, 2012
  6. Jeff KingOct 6, 2012
  7. Junio C HamanoOct 6, 2012
  8. Jeff KingOct 6, 2012
  9. Conrad IrwinOct 6, 2012
  10. Jeff KingOct 6, 2012
  11. Junio C HamanoOct 7, 2012
  12. Jeff KingOct 7, 2012
  13. Junio C HamanoOct 7, 2012
  14. Jeff KingOct 7, 2012
  15. Conrad IrwinOct 11, 2012
  16. Junio C HamanoOct 11, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.