git/list[1] front-page[2] threads[3] people[4] search[5] about
wed 2026-10-07 17:27 UTC

Re: [PATCH v3 0/3] Git commit --patch (again)

From
Conrad Irwin <conrad.irwin@gmail.com>
Date
May 10, 2011, 06:42 UTC
Message-ID
<BANLkTikwjZkzMxksBsVTFRYdhE3L6ZQM0A@mail.gmail.com>
In-Reply-To
<20110509144451.GA11362@sigill.intra.peff.net>
On Mon, May 9, 2011 at 7:44 AM, Jeff King <peff@peff.net> wrote:
Show 6 quoted lines
>
> That still leaves an inconsistency in "git add -p" versus "git commit
> -p" (e.g., if you abort "git add -p" with "^C"). But if we care, the
> right solution is probably to make "git add -p" atomic. That can be a
> separate topic, though, and I'm not sure anyone really cares enough to
> work on it.

I have pondered this problem too. "git add -p" is a particularly unintuitive, it inherits the update-the-index-after-every-complete-file semantics of "git add --interactive", but without ever making the file boundaries clear to the user. Depending on how much this bugs me, I might try to fix it in the future, but I wonder whether any users of "git add --interactive" are relying on the file based granularity.

Show 8 quoted lines
>
> I have one final question. If I do abort a commit, is there any way to
> recover the state that was in the temporary index? That is, if I abort
> "git commit -i" by using an empty commit message, it is easy enough to
> use shell history to repeat the command (possibly with a different set
> of files). But if I spend some time selecting (and possibly editing)
> hunks, and then decide to abort the commit, is there any way to recover
> the intermediate index state?

Not really. You could use your knowledge of git-commit to assume that the tree object with the most recent ctime is probably useful, but that only works some of the time. The occasions on which I have wanted to abort the process half-way, I've just created a temporary commit with what I have so far. A "git reset --soft" at that point makes the whole process long-hand for "git add -p".

Show 6 quoted lines
>
>>   Allow git commit --interactive with paths
>
> Hmm. Test t7501.8 explicitly tests that this isn't allowed. But the test
> is poorly written, and falsely returns success even with your patch.
>
Well spotted. Thank you Junio for fixing that test.
> which does properly fail with your change. Your commit should tweak that
> test (speaking of which, it would be nice for patch 1 to have a test,
> too).
I'll try to get my head around the tests :).
Conrad
Previous: Junio C HamanoNext: Conrad Irwin
Message 16 of 21 in “Git commit --patch (again)”
  1. 0/3 Git commit --patch (again)conrad.irwin@gmail.com, May 7, 2011
  2. 1/3 Use a temporary index for git commit --interactiveconrad.irwin@gmail.com, May 7, 2011
  3. 2/3 Allow git commit --interactive with pathsconrad.irwin@gmail.com, May 7, 2011
  4. 3/3 Add support for -p/--patch to git-commitconrad.irwin@gmail.com, May 7, 2011
  5. Sverre RabbelierMay 7, 2011
  6. Valentin HaenelMay 7, 2011
  7. Conrad IrwinMay 7, 2011
  8. 3/3 Add support for -p/--patch to git-commitConrad Irwin, May 7, 2011
  9. Add commit to list of config.singlekey commandsConrad Irwin, May 7, 2011
  10. Junio C HamanoMay 8, 2011
  11. Jeff KingMay 9, 2011
  12. Junio C HamanoMay 9, 2011
  13. Jeff KingMay 9, 2011
  14. Junio C HamanoMay 9, 2011
  15. Junio C HamanoMay 9, 2011
  16. Conrad IrwinMay 10, 2011
  17. Test atomic git-commit --interactiveConrad Irwin, May 10, 2011
  18. Jeff KingMay 10, 2011
  19. Jeff KingMay 10, 2011
  20. Jeff KingMay 10, 2011
  21. Conrad IrwinMay 10, 2011

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.