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

Re: Request: git add --interactive: split hunk: When can't split further, split on empty lines

From
Philip Oakley <philipoakley@iee.org>
Date
May 30, 2019, 19:26 UTC
Message-ID
<aad93135-6280-ac6a-c72a-8a325fbbaf67@iee.org>
In-Reply-To
<nycvar.QRO.7.76.6.1905301644020.44@tvgsbejvaqbjf.bet>

Hi,  some minor comments. On 30/05/2019 15:53, Johannes Schindelin wrote:

Show 9 quoted lines
> Hi James,
>
> On Wed, 29 May 2019, James Harvey wrote:
>
>> When adding interactively, 's' can be used to split the current hunk.
>> Once it gets down to where 's' reports "Sorry, cannot split this
>> hunk", it could be useful if it would then start splitting based on
>> empty lines, probably leaving empty lines at the top of the split
>> hunks.  It certainly wouldn't be perfect, and might create many hunks,

A binary search style split may be an option to avoid the 'many hunks' issue.

Show 13 quoted lines
>> but it would be a nice alternative to manually editing the hunk.
>> Certainly someone could still manually edit the hunk if they didn't
>> want to use it in a particular situation.
> While a neat idea from the users' perspective, I think that it is
> technically a bit challenging, as you then have a problem to coalesce the
> patches appropriately.
>
> The thing with the splitting at context lines is that you have a much
> easier time to merge individual split-hunks into a "coalesced" hunk
> because the context lines stay context lines.
>
> Having said that, there was a patch series recently to add the ability to
> stage individual lines,

I believe that the git-gui (in tk/tcl, but using git commands) was already able to stage individual/selected lines, so there may be some ideas from there.

Show 13 quoted lines
> and I think that your feature request could be
> implemented on top of that.
>
> In the meantime, an Outreachy intern and I worked on turning `git add -i`
> into a built-in (it was written in Perl, and the built-in is written in
> portable C instead), and I *think* that the plan with the patch series to
> stage individual lines was to re-implement it on top of the built-in patch
> series.
>
> Would you be interested in participating in that project?
>
> Ciao,
> Johannes

-- Philip

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 3 of 5 in “Request: git add --interactive: split hunk: When can't split further, split on empty lines”
  1. James HarveyMay 30, 2019
  2. Johannes SchindelinMay 30, 2019
  3. Philip OakleyMay 30, 2019
  4. Johannes SchindelinMay 30, 2019
  5. Philip OakleyMay 30, 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.