diff options
author | Phillip Wood <phillip.wood@dunelm.org.uk> | 2018-03-05 10:56:28 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-05 10:45:41 -0800 |
commit | 2b8ea7f3c7d8dfd4f1eddaef6688b51f8106767e (patch) | |
tree | 8e00fb99ceb854c1f89a13372c6718e64cf41e5e /t | |
parent | add -p: adjust offsets of subsequent hunks when one is skipped (diff) | |
download | tgif-2b8ea7f3c7d8dfd4f1eddaef6688b51f8106767e.tar.xz |
add -p: calculate offset delta for edited patches
Recount the number of preimage and postimage lines in a hunk after it
has been edited so any change in the number of insertions or deletions
can be used to adjust the offsets of subsequent hunks. If an edited
hunk is subsequently split then the offset correction will be lost. It
would be possible to fix this if it is a problem, however the code
here is still an improvement on the status quo for the common case
where an edited hunk is applied without being split.
This is also a necessary step to removing '--recount' and
'--allow-overlap' from the invocation of 'git apply'. Before
'--recount' can be removed the splitting and coalescing counting needs
to be fixed to handle a missing newline at the end of a file. In order
to remove '--allow-overlap' there needs to be i) some way of verifying
the offset data in the edited hunk (probably by correlating the
preimage (or postimage if the patch is going to be applied in reverse)
lines of the edited and unedited versions to see if they are offset or
if any leading/trailing context lines have been removed) and ii) a way of
dealing with edited hunks that change context lines that are shared
with neighbouring hunks.
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t3701-add-interactive.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 6f18a92486..24ed3f4a22 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -504,7 +504,7 @@ test_expect_success 'add -p works with pathological context lines' ' test_cmp expected-1 actual ' -test_expect_failure 'add -p patch editing works with pathological context lines' ' +test_expect_success 'add -p patch editing works with pathological context lines' ' git reset && # n q q below is in case edit fails printf "%s\n" e y n q q | |