Skip to content

Commit 5667141

Browse files
pks-tgitster
authored andcommitted
fetch: fix --no-recurse-submodules with multi-remote fetches
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 667fcf4 commit 5667141

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

builtin/fetch.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,8 @@ static void add_options_to_argv(struct strvec *argv)
18791879
strvec_push(argv, "--keep");
18801880
if (recurse_submodules == RECURSE_SUBMODULES_ON)
18811881
strvec_push(argv, "--recurse-submodules");
1882+
else if (recurse_submodules == RECURSE_SUBMODULES_OFF)
1883+
strvec_push(argv, "--no-recurse-submodules");
18821884
else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
18831885
strvec_push(argv, "--recurse-submodules=on-demand");
18841886
if (tags == TAGS_SET)

t/t5526-fetch-submodules.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,4 +1180,17 @@ test_expect_success 'fetch --all with --recurse-submodules with multiple' '
11801180
test_line_count = 2 fetch-subs
11811181
'
11821182

1183+
test_expect_success "fetch --all with --no-recurse-submodules only fetches superproject" '
1184+
test_when_finished "rm -rf src_clone" &&
1185+
1186+
git clone --recurse-submodules src src_clone &&
1187+
(
1188+
cd src_clone &&
1189+
git remote add secondary ../src &&
1190+
git config submodule.recurse true &&
1191+
git fetch --all --no-recurse-submodules 2>../fetch-log
1192+
) &&
1193+
! grep "Fetching submodule" fetch-log
1194+
'
1195+
11831196
test_done

0 commit comments

Comments
 (0)