]> git.ipfire.org Git - thirdparty/git.git/commit
fetch: respect --server-option when fetching multiple remotes
authorXing Xin <xingxin.xx@bytedance.com>
Tue, 8 Oct 2024 03:38:18 +0000 (03:38 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Oct 2024 17:22:09 +0000 (10:22 -0700)
commit148bc7bf4b482edd7919e3071542abeb5d7ea4af
tree666d120a8db4717eeef89a648bfb7efd93b27dfd
parent094f78a16a6c150ff125afd9c3f2773b47384c06
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>
builtin/fetch.c
t/t5702-protocol-v2.sh