diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2022-01-11 11:12:10 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-01-12 10:29:53 -0800 |
commit | 7008ddc645cf8a6783d23b4ccdae0b74b096bd9e (patch) | |
tree | 2101f68fbb4cfdfea064946b0c98bf478a6c07fb /t/t0023-crlf-am.sh | |
parent | t3701: clean up hunk splitting tests (diff) | |
download | tgif-7008ddc645cf8a6783d23b4ccdae0b74b096bd9e.tar.xz |
builtin add -p: fix hunk splitting
The C reimplementation of "add -p" fails to split the last hunk in a
file if hunk ends with an addition or deletion without any post context
line unless it is the last file to be processed.
To determine whether a hunk can be split a counter is incremented each
time a context line follows an insertion or deletion. If at the end of
the hunk the value of this counter is greater than one then the hunk
can be split into that number of smaller hunks. If the last hunk in a
file ends with an insertion or deletion then there is no following
context line and the counter will not be incremented. This case is
already handled at the end of the loop where counter is incremented if
the last hunk ended with an insertion or deletion. Unfortunately there
is no similar check between files (likely because the perl version
only ever parses one diff at a time). Fix this by checking if the last
hunk ended with an insertion or deletion when we see the diff header
of a new file and extend the existing regression test.
Reproted-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0023-crlf-am.sh')
0 files changed, 0 insertions, 0 deletions