diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-08-30 16:06:04 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-08-30 16:06:04 -0700 |
commit | 7e3b9d15344fa5a09fe5c70270c9f2c2f75d0f90 (patch) | |
tree | ccd77cab4aa38b32c5b6caddbc4850dd5aac014c /t | |
parent | Merge branch 'jc/userdiff-pattern-hint' (diff) | |
parent | apply: keep buffer/size pair in sync when parsing binary hunks (diff) | |
download | tgif-7e3b9d15344fa5a09fe5c70270c9f2c2f75d0f90.tar.xz |
Merge branch 'jk/apply-binary-hunk-parsing-fix'
"git apply" miscounted the bytes and failed to read to the end of
binary hunks.
* jk/apply-binary-hunk-parsing-fix:
apply: keep buffer/size pair in sync when parsing binary hunks
Diffstat (limited to 't')
-rwxr-xr-x | t/t4103-apply-binary.sh | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/t/t4103-apply-binary.sh b/t/t4103-apply-binary.sh index fad6d3f542..d370ecfe0d 100755 --- a/t/t4103-apply-binary.sh +++ b/t/t4103-apply-binary.sh @@ -158,4 +158,27 @@ test_expect_success 'apply binary -p0 diff' ' test -z "$(git diff --name-status binary -- file3)" ' +test_expect_success 'reject truncated binary diff' ' + do_reset && + + # this length is calculated to get us very close to + # the 8192-byte strbuf we will use to read in the patch. + test-tool genrandom foo 6205 >file1 && + git diff --binary >patch && + + # truncate the patch at the second "literal" line, + # but exclude the trailing newline. We must use perl + # for this, since tools like "sed" cannot reliably + # produce output without the trailing newline. + perl -pe " + if (/^literal/ && \$count++ >= 1) { + chomp; + print; + exit 0; + } + " <patch >patch.trunc && + + do_reset && + test_must_fail git apply patch.trunc +' test_done |