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

Re: Autosplit option for git add -p

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 8, 2024, 18:53 UTC
Message-ID
<xmqqmsnvclle.fsf@gitster.g>
In-Reply-To
<CAP8UFD3JM_h1BvK59R4wT1DeZyo6o-9T3GXGK8xE6vLnDMDCaQ@mail.gmail.com>
Christian Couder <christian.couder@gmail.com> writes:
> It doesn't look like there is any option to do that. About
> implementing it, it depends if it would be a command line option or a
> config option.
Having these alone make no sense to me.

I'd suggest extending the lowest level (i.e. interactive prompt response) first so that a stronger 's' splits all hunks in the current file. It might be sufficient for the use case.

On top of that, it happens to be that when changes to _all_ paths want to be split, it may prove handy to also have a command line option.

But the reason why I am hesitant to endorse a command line option that splits everything is because:

 (1) it is dubious to expect the user to _know_ that it makes sense
     to split all changes before starting "add -p" (and friends).
 (2) if the user gives such an option and then in the interactive
     session regrets that it was too much to split all the hunks, it
     is unclear how the user can easily recover (there is no "merge
     all hunks back to the original" operation).
Previous: Dragan Simic
Message 4 of 4 in “Autosplit option for git add -p”
  1. Konstantin TokarevJun 7, 2024
  2. Christian CouderJun 8, 2024
  3. Dragan SimicJun 8, 2024
  4. Junio C HamanoJun 8, 2024

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.