]> git.ipfire.org Git - thirdparty/git.git/commitdiff
fetch: fix `--no-recurse-submodules` with multi-remote fetches
authorPatrick Steinhardt <ps@pks.im>
Wed, 10 May 2023 12:34:02 +0000 (14:34 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 May 2023 17:35:24 +0000 (10:35 -0700)
When running `git fetch --no-recurse-submodules`, the exectation is that
we don't fetch any submodules. And while this works for fetches of a
single remote, it doesn't when fetching multiple remotes at once. The
result is that we do recurse into submodules even though the user has
explicitly asked us not to.

This is because while we pass on `--recurse-submodules={yes,on-demand}`
if specified by the user, we don't pass on `--no-recurse-submodules` to
the subprocess spawned to perform the submodule fetch.

Fix this by also forwarding this flag as expected.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
t/t5526-fetch-submodules.sh

index 85bd2801036a8401a096043e26db1aeadc44d325..71959b2479cc75d839099fb06cc3ccc4736bb924 100644 (file)
@@ -1879,6 +1879,8 @@ static void add_options_to_argv(struct strvec *argv)
                strvec_push(argv, "--keep");
        if (recurse_submodules == RECURSE_SUBMODULES_ON)
                strvec_push(argv, "--recurse-submodules");
+       else if (recurse_submodules == RECURSE_SUBMODULES_OFF)
+               strvec_push(argv, "--no-recurse-submodules");
        else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
                strvec_push(argv, "--recurse-submodules=on-demand");
        if (tags == TAGS_SET)
index dcdbe26a08e1e3db99338a740e10011981b292af..26e933f93ae7f72261046495f25f63af8c31349d 100755 (executable)
@@ -1180,4 +1180,17 @@ test_expect_success 'fetch --all with --recurse-submodules with multiple' '
        test_line_count = 2 fetch-subs
 '
 
+test_expect_success "fetch --all with --no-recurse-submodules only fetches superproject" '
+       test_when_finished "rm -rf src_clone" &&
+
+       git clone --recurse-submodules src src_clone &&
+       (
+               cd src_clone &&
+               git remote add secondary ../src &&
+               git config submodule.recurse true &&
+               git fetch --all --no-recurse-submodules 2>../fetch-log
+       ) &&
+       ! grep "Fetching submodule" fetch-log
+'
+
 test_done