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 From de4eaae63a87ee33baf477ed10e6e97d649084cf Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 20 Jan 2022 13:58:43 -0800 Subject: fetch: help translators by reusing the same message template Follow the example set by 12909b6b (i18n: turn "options are incompatible" into "cannot be used together", 2022-01-05) and use the same message string to reduce the need for translation. Reported-by: Jiang Xin Helped-by: Glen Choo Signed-off-by: Junio C Hamano --- t/t5702-protocol-v2.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 't/t5702-protocol-v2.sh') diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 3f3ad24299..b83f3f5ffe 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -630,7 +630,7 @@ test_expect_success 'usage: --negotiate-only without --negotiation-tip' ' test_expect_success 'usage: --negotiate-only with --recurse-submodules' ' cat >err.expect <<-\EOF && - fatal: --negotiate-only and --recurse-submodules cannot be used together + fatal: options '\''--negotiate-only'\'' and '\''--recurse-submodules'\'' cannot be used together EOF test_must_fail git -c protocol.version=2 -C client fetch \ -- cgit v1.2.3