From 0cf5fbc2e4ee124b4dc583fac6f7ad697616a56a Mon Sep 17 00:00:00 2001 From: Matt Cooper Date: Thu, 24 Feb 2022 00:07:20 +0000 Subject: index-pack: clarify the breached limit As a small courtesy to users, report what limit was breached. This is especially useful when a push exceeds a server-defined limit, since the user is unlikely to have configured the limit (their host did). Also demonstrate the human-readable message in a test. Helped-by: Taylor Blau Helped-by: Derrick Stolee Signed-off-by: Matt Cooper Signed-off-by: Junio C Hamano --- builtin/index-pack.c | 8 ++++++-- t/t5302-pack-index.sh | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 3c2e6aee3c..c45273de3b 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -323,8 +323,12 @@ static void use(int bytes) if (signed_add_overflows(consumed_bytes, bytes)) die(_("pack too large for current definition of off_t")); consumed_bytes += bytes; - if (max_input_size && consumed_bytes > max_input_size) - die(_("pack exceeds maximum allowed size")); + if (max_input_size && consumed_bytes > max_input_size) { + struct strbuf size_limit = STRBUF_INIT; + strbuf_humanise_bytes(&size_limit, max_input_size); + die(_("pack exceeds maximum allowed size (%s)"), + size_limit.buf); + } } static const char *open_pack_file(const char *pack_name) diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 8ee67df38f..b0095ab41d 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -284,4 +284,12 @@ test_expect_success 'index-pack -v --stdin produces progress for both phases' ' test_i18ngrep "Resolving deltas" err ' +test_expect_success 'too-large packs report the breach' ' + pack=$(git pack-objects --all pack err && + grep "maximum allowed size (20 bytes)" err +' + test_done -- cgit v1.2.3