Web lists-archives.com

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

Hi Philip,

On Thu, 30 May 2019, Philip Oakley wrote:

> On 30/05/2019 15:53, Johannes Schindelin wrote:
> >
> > 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.

Sadly, no.

There is one very big difference between Git GUI and `git add -p`: when
you stage a line in Git GUI, it is staged *immediately*.

When you stage a single line in the Git GUI, the diff you see in the
window is reloaded. That is quite slow in the long run, and no fun.

In contrast, `git add -p` does not stage *anything* until you're done
selecting what you want to stage.

Therefore, `git add -p` does have to do things quite a bit differently, as
it will have to eventually build a single diff that is applied in one fell
swoop, no matter how many lines you select individually.

And naturally, there is also the difference between the user interfaces:
while you can ask the user to select (part of) the line to stage in Git
GUI via the mouse, that is not at all an option in `git add -p`.

Likewise, the very convenient option to navigate via regular expressions
in `git add -p` is not available in Git GUI at all.

In short: I think that it makes more sense to come up with a design
specific to `git add -p` and not get distracted by Tcl code that works
quite differently.