summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-11-27 11:06:36 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-11-27 11:06:36 +0900
commitd78a122e9cb33df8e625fcf15cb075cc6d61b984 (patch)
treea98238497bb2fed0f557736147d44099a41126cf
parentMerge branch 'pw/sequencer-recover-from-unlockable-index' (diff)
parentapply: update line lengths for --inaccurate-eof (diff)
downloadtgif-d78a122e9cb33df8e625fcf15cb075cc6d61b984.tar.xz
Merge branch 'rs/apply-inaccurate-eof-with-incomplete-line'
"git apply --inaccurate-eof" when used with "--ignore-space-change" triggered an internal sanity check, which has been fixed. * rs/apply-inaccurate-eof-with-incomplete-line: apply: update line lengths for --inaccurate-eof
-rw-r--r--apply.c2
-rwxr-xr-xt/t4107-apply-ignore-whitespace.sh14
2 files changed, 16 insertions, 0 deletions
diff --git a/apply.c b/apply.c
index b8087bd29c..321a9fa68d 100644
--- a/apply.c
+++ b/apply.c
@@ -2953,6 +2953,8 @@ static int apply_one_fragment(struct apply_state *state,
newlines.len > 0 && newlines.buf[newlines.len - 1] == '\n') {
old--;
strbuf_setlen(&newlines, newlines.len - 1);
+ preimage.line_allocated[preimage.nr - 1].len--;
+ postimage.line_allocated[postimage.nr - 1].len--;
}
leading = frag->leading;
diff --git a/t/t4107-apply-ignore-whitespace.sh b/t/t4107-apply-ignore-whitespace.sh
index 9e29b5262d..ac72eeaf27 100755
--- a/t/t4107-apply-ignore-whitespace.sh
+++ b/t/t4107-apply-ignore-whitespace.sh
@@ -178,4 +178,18 @@ test_expect_success 'patch5 fails (--no-ignore-whitespace)' '
test_must_fail git apply --no-ignore-whitespace patch5.patch
'
+test_expect_success 'apply --ignore-space-change --inaccurate-eof' '
+ echo 1 >file &&
+ git apply --ignore-space-change --inaccurate-eof <<-\EOF &&
+ diff --git a/file b/file
+ --- a/file
+ +++ b/file
+ @@ -1 +1 @@
+ -1
+ +2
+ EOF
+ printf 2 >expect &&
+ test_cmp expect file
+'
+
test_done