aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2023-07-06 11:54:47 -0700
committerJunio C Hamano <gitster@pobox.com>2023-07-06 11:54:47 -0700
commit84b889bd035886cb19b1e9a9524dcf8a431836cd (patch)
tree6f86b3cc3d0aabcaf319e1d51931a7e7559c9369
parentMerge branch 'tl/notes-separator' (diff)
parentapply: improve error messages when reading patch (diff)
downloadgit-84b889bd035886cb19b1e9a9524dcf8a431836cd.tar.gz
git-84b889bd035886cb19b1e9a9524dcf8a431836cd.zip
Merge branch 'pw/apply-too-large'
"git apply" punts when it is fed too large a patch input; the error message it gives when it happens has been clarified. * pw/apply-too-large: apply: improve error messages when reading patch
-rw-r--r--apply.c7
-rwxr-xr-xt/t4141-apply-too-large.sh2
2 files changed, 5 insertions, 4 deletions
diff --git a/apply.c b/apply.c
index 8bd0109fcc..45dcd645e6 100644
--- a/apply.c
+++ b/apply.c
@@ -414,9 +414,10 @@ static void say_patch_name(FILE *output, const char *fmt, struct patch *patch)
static int read_patch_file(struct strbuf *sb, int fd)
{
- if (strbuf_read(sb, fd, 0) < 0 || sb->len >= MAX_APPLY_SIZE)
- return error_errno("git apply: failed to read");
-
+ if (strbuf_read(sb, fd, 0) < 0)
+ return error_errno(_("failed to read patch"));
+ else if (sb->len >= MAX_APPLY_SIZE)
+ return error(_("patch too large"));
/*
* Make sure that we have some slop in the buffer
* so that we can do speculative "memcmp" etc, and
diff --git a/t/t4141-apply-too-large.sh b/t/t4141-apply-too-large.sh
index 58742d4fc5..20cc1209f6 100755
--- a/t/t4141-apply-too-large.sh
+++ b/t/t4141-apply-too-large.sh
@@ -17,7 +17,7 @@ test_expect_success EXPENSIVE 'git apply rejects patches that are too large' '
EOF
test-tool genzeros
} | test_copy_bytes $sz | test_must_fail git apply 2>err &&
- grep "git apply: failed to read" err
+ grep "patch too large" err
'
test_done