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

Re: Stage or discard a hunk at a time?

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Apr 30, 2019, 23:19 UTC
Message-ID
<nycvar.QRO.7.76.6.1904301918230.45@tvgsbejvaqbjf.bet>
In-Reply-To
<20190422192821.GA22798@sigill.intra.peff.net>
Hi,
On Mon, 22 Apr 2019, Jeff King wrote:
Show 23 quoted lines
> On Wed, Jan 16, 2019 at 01:09:03PM -0600, Cameron Steffen wrote:
>
> > I have this feature idea for git. There should be a command that
> > effectively combines git add -p and git checkout -p so that I can
> > navigate changed hunks and either stage or discard them.
> >
> > There is already a SO question asking about this exactly...
> > https://stackoverflow.com/questions/11538650/simultaneously-git-add-p-and-git-checkout-p
> >
> > Has this been discussed before? Is this a reasonable request? If so, I
> > might look into contributing the change myself.
>
> This is something I've sometimes wanted, too. I don't think it would be
> _too_ hard to do by modifying the add-interactive code. Both of those
> operations are driven by the same code; see the %patch_modes hash in
> git-add--interactive.perl, which defines the various situations. You
> would need to modify the actual code to handle the tri-state (there is
> not just "yes, apply it" and "no, leave it alone", but now "apply /
> discard / skip"). But it seems do-able.
>
> If you do plan to work on it, be aware that the perl bits of
> add--interactive are being re-written in C. So it might make sense to
> target the new C implementation instead of modifying the perl.

The work on that is tracked in PRs 170-175 on https://github.com/gitgitgadget/git, i.e.

- https://github.com/gitgitgadget/git/pull/170
- https://github.com/gitgitgadget/git/pull/171
- https://github.com/gitgitgadget/git/pull/172
- https://github.com/gitgitgadget/git/pull/173
- https://github.com/gitgitgadget/git/pull/174
- https://github.com/gitgitgadget/git/pull/175

Ciao, Johannes

Previous: Jeff KingNext: David Aguilar
Message 3 of 4 in “Stage or discard a hunk at a time?”
  1. Cameron SteffenJan 16, 2019
  2. Jeff KingApr 22, 2019
  3. Johannes SchindelinApr 30, 2019
  4. David AguilarApr 28, 2019

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.