diff options
author | Johannes Schindelin <johannes.schindelin@gmx.de> | 2019-12-13 08:07:58 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-12-13 12:37:14 -0800 |
commit | 510aeca199c4feeb38d318cc151ecf5464a3a865 (patch) | |
tree | 5a24216378afec1d5b295f12dc62f987c9c3d56d /aclocal.m4 | |
parent | built-in add -p: show different prompts for mode changes and deletions (diff) | |
download | tgif-510aeca199c4feeb38d318cc151ecf5464a3a865.tar.xz |
built-in add -p: implement the hunk splitting feature
If this developer's workflow is any indication, then this is *the* most
useful feature of Git's interactive `add `command.
Note: once again, this is not a verbatim conversion from the Perl code
to C: the `hunk_splittable()` function, for example, essentially did all
the work of splitting the hunk, just to find out whether more than one
hunk would have been the result (and then tossed that result into the
trash). In C we instead count the number of resulting hunks (without
actually doing the work of splitting, but just counting the transitions
from non-context lines to context lines), and store that information
with the hunk, and we do that *while* parsing the diff in the first
place.
Another deviation: the built-in `git add -p` was designed with a single
strbuf holding the diff (and another one holding the colored diff, if
that one was asked for) in mind, and hunks essentially store just the
start and end offsets pointing into that strbuf. As a consequence, when
we split hunks, we now use a special mode where the hunk header is
generated dynamically, and only the rest of the hunk is stored using
such start/end offsets. This way, we also avoid the frequent
formatting/re-parsing of the hunk header of the Perl version.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'aclocal.m4')
0 files changed, 0 insertions, 0 deletions