From 386c076a863cfafd733b71564245be973e3d1bda Mon Sep 17 00:00:00 2001 From: Glen Choo Date: Tue, 18 Jan 2022 16:00:56 -0800 Subject: fetch --negotiate-only: do not update submodules `git fetch --negotiate-only` is an implementation detail of push negotiation and, unlike most `git fetch` invocations, does not actually update the main repository. Thus it should not update submodules even if submodule recursion is enabled. This is not just slow, it is wrong e.g. push negotiation with "submodule.recurse=true" will cause submodules to be updated because it invokes `git fetch --negotiate-only`. Fix this by disabling submodule recursion if --negotiate-only was given. Since this makes --negotiate-only and --recurse-submodules incompatible, check for this invalid combination and die. This does not use the "goto cleanup" introduced in the previous commit because we want to recurse through submodules whenever a ref is fetched, and this can happen without introducing new objects. Signed-off-by: Glen Choo Signed-off-by: Junio C Hamano --- t/t5702-protocol-v2.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 't/t5702-protocol-v2.sh') diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 78f85b0714..3f3ad24299 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -628,6 +628,18 @@ test_expect_success 'usage: --negotiate-only without --negotiation-tip' ' test_cmp err.expect err.actual ' +test_expect_success 'usage: --negotiate-only with --recurse-submodules' ' + cat >err.expect <<-\EOF && + fatal: --negotiate-only and --recurse-submodules cannot be used together + EOF + + test_must_fail git -c protocol.version=2 -C client fetch \ + --negotiate-only \ + --recurse-submodules \ + origin 2>err.actual && + test_cmp err.expect err.actual +' + test_expect_success 'file:// --negotiate-only' ' SERVER="server" && URI="file://$(pwd)/server" && -- cgit v1.2.3