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

Re: Can we do better than "git checkout/add -p"

From
Jeff King <peff@peff.net>
Date
Aug 12, 2026, 21:44 UTC
Message-ID
<20260812214403.GD152730@coredump.intra.peff.net>
In-Reply-To
<21db84ba-3894-23e9-9f17-ceeafb1990c2@gmx.de>
On Wed, Aug 12, 2026 at 10:40:08AM +0200, Johannes Schindelin wrote:
Show 22 quoted lines
> > My current workaround is not to use "git checkout -p" and instead
> > (e)dit an undesirable hunk into a no-op hunk.  This is serviceable,
> > but with two caveats:
> > 
> >  - The underlying 'apply' machinery does not see a truly no-op,
> >    context-only hunk.  You'd need to pretend removing an existing
> >    line and adding the same line back.
> > 
> >  - (e)dit applies the edited hunk right away without giving the user
> >    a chance to proofread and approve or reedit.
> 
> I, too, often find myself in exactly that kind of need. That's why I was
> *so* disappointed when
> https://lore.kernel.org/git/20260325075055.354709-1-luizedc1@gmail.com/
> was shot down unceremoniously. I still think that would be a good
> addition. I even opened https://github.com/gitgitgadget/git/issues/1828
> and sketched
> https://github.com/git/git/compare/master...dscho:git:add-p-stash-mode to
> the same extent.
> 
> Maybe it is time to revisit that verdict, and see whether there is really
> no way to accept that clearly needed functionality.

Thanks for digging up that link. After reading Junio's message that started this thread, I _thought_ we had discussed this a dozen times already, but after searching the archive could only come up with this thread:

  https://lore.kernel.org/git/20161102223705.qycdo3j2bvndi7ev@sigill.intra.peff.net/

But the one you linked is another example, and nicely links back recursively to at least two other instances. ;)

I see I am quoted in one of them as "it's a little weird for add -p to change the working tree", but I want to make clear that I _don't_ oppose a feature like this. I think it would be super useful. We may find a way to avoid that "weird" property (e.g., by putting the "combined" stash/add mode under a different command's "-p"), or we may just accept it.

-Peff
Previous: Johannes SchindelinNext: Junio C Hamano
Message 13 of 15 in “Can we do better than "git checkout/add -p"”
  1. Junio C HamanoAug 7, 2026
  2. Christian CouderAug 7, 2026
  3. D. Ben KnobleAug 7, 2026
  4. Junio C HamanoAug 7, 2026
  5. D. Ben KnobleAug 7, 2026
  6. Junio C HamanoAug 7, 2026
  7. Patrick SteinhardtAug 10, 2026
  8. Stefan HallerAug 10, 2026
  9. Patrick SteinhardtAug 10, 2026
  10. Junio C HamanoAug 10, 2026
  11. Patrick SteinhardtAug 11, 2026
  12. Johannes SchindelinAug 12, 2026
  13. Jeff KingAug 12, 2026
  14. Junio C HamanoAug 12, 2026
  15. Junio C HamanoAug 12, 2026

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.