All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: git@vger.kernel.org
Cc: Taylor Blau <me@ttaylorr.com>
Subject: [PATCH] upload-pack: propagate return value from object filter config callback
Date: Thu, 3 Dec 2020 03:09:42 -0500	[thread overview]
Message-ID: <X8idRpUCgV8rNeA6@coredump.intra.peff.net> (raw)

If we encounter an error in parse_filter_object_config(), we'll complain
to stderr but won't actually propagate the return value up the stack.
This is unlike most of our config callbacks, which return the error to
git_config() so it can die (this includes the call just below us to
parse_hide_refs_config(), which can also produce errors).

Signed-off-by: Jeff King <peff@peff.net>
---
The changed code is from 6dd3456a8c (upload-pack.c: allow banning
certain object filter(s), 2020-08-03), but it was not until 5b01a4e8ff
(upload-pack.c: introduce 'uploadpackfilter.tree.maxDepth', 2020-08-03)
that the function could actually return an error (and so the test
doesn't work until then). Applying on top of tb/upload-pack-filters is
reasonable.

 t/t5616-partial-clone.sh | 8 ++++++++
 upload-pack.c            | 3 ++-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/t/t5616-partial-clone.sh b/t/t5616-partial-clone.sh
index f4d49d8335..2ea66205cf 100755
--- a/t/t5616-partial-clone.sh
+++ b/t/t5616-partial-clone.sh
@@ -251,6 +251,14 @@ test_expect_success 'implicitly construct combine: filter with repeated flags' '
 	test_cmp unique_types.expected unique_types.actual
 '
 
+test_expect_success 'upload-pack complains of bogus filter config' '
+	printf 0000 |
+	test_must_fail git \
+		-c uploadpackfilter.tree.maxdepth \
+		upload-pack . >/dev/null 2>err &&
+	test_i18ngrep "unable to parse.*tree.maxdepth" err
+'
+
 test_expect_success 'upload-pack fails banned object filters' '
 	test_config -C srv.bare uploadpackfilter.blob:none.allow false &&
 	test_must_fail ok=sigpipe git clone --no-checkout --filter=blob:none \
diff --git a/upload-pack.c b/upload-pack.c
index 5dc8e1f844..57a22d14f2 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1307,7 +1307,8 @@ static int upload_pack_config(const char *var, const char *value, void *cb_data)
 			return git_config_string(&data->pack_objects_hook, var, value);
 	}
 
-	parse_object_filter_config(var, value, data);
+	if (parse_object_filter_config(var, value, data) < 0)
+		return -1;
 
 	return parse_hide_refs_config(var, value, "uploadpack");
 }
-- 
2.29.2.896.g080220a959

                 reply	other threads:[~2020-12-03  8:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X8idRpUCgV8rNeA6@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=me@ttaylorr.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.