1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-21 17:26:09 +02:00

Merge branch 'rs/apply-inaccurate-eof-with-incomplete-line' into maint

"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
This commit is contained in:
Junio C Hamano 2017-12-06 09:09:03 -08:00
commit 43240cb731
2 changed files with 16 additions and 0 deletions

View File

@ -2958,6 +2958,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;

View File

@ -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