aboutsummaryrefslogtreecommitdiffstats
path: root/builtin/fetch.c
diff options
context:
space:
mode:
authorXing Xin <xingxin.xx@bytedance.com>2024-10-08 03:38:18 +0000
committerJunio C Hamano <gitster@pobox.com>2024-10-08 10:22:09 -0700
commit148bc7bf4b482edd7919e3071542abeb5d7ea4af (patch)
tree666d120a8db4717eeef89a648bfb7efd93b27dfd /builtin/fetch.c
parenttransport.c::handshake: make use of server options from remote (diff)
downloadgit-148bc7bf4b482edd7919e3071542abeb5d7ea4af.tar.gz
git-148bc7bf4b482edd7919e3071542abeb5d7ea4af.zip
fetch: respect --server-option when fetching multiple remotes
Fix an issue where server options specified via the command line (`--server-option` or `-o`) were not sent when fetching from multiple remotes using Git protocol v2. To reproduce the issue with a repository containing multiple remotes: GIT_TRACE_PACKET=1 git -c protocol.version=2 fetch --server-option=demo --all Observe that no server options are sent to any remote. The root cause was identified in `builtin/fetch.c:fetch_multiple`, which is invoked when fetching from more than one remote. This function forks a `git-fetch` subprocess for each remote but did not include the specified server options in the subprocess arguments. This commit ensures that command-line specified server options are properly passed to each subprocess. Relevant tests have been added. Signed-off-by: Xing Xin <xingxin.xx@bytedance.com> Reviewed-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/fetch.c')
-rw-r--r--builtin/fetch.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 80a64d0d26..d9027e4dc9 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -1981,6 +1981,8 @@ static int fetch_multiple(struct string_list *list, int max_children,
strvec_pushl(&argv, "-c", "fetch.bundleURI=",
"fetch", "--append", "--no-auto-gc",
"--no-write-commit-graph", NULL);
+ for (i = 0; i < server_options.nr; i++)
+ strvec_pushf(&argv, "--server-option=%s", server_options.items[i].string);
add_options_to_argv(&argv, config);
if (max_children != 1 && list->nr != 1) {