]> git.99rst.org Git - git.git/commit
fetch-pack: drop the static advertise_sid variable
authorPablo Sabater <redacted>
Fri, 24 Jul 2026 10:54:15 +0000 (12:54 +0200)
committerJunio C Hamano <redacted>
Fri, 24 Jul 2026 15:46:58 +0000 (08:46 -0700)
commitb54d5e19f068a73bdbde5a9434fe72902764b958
treed4de6e76d1d85e4bf81f068a965e2316c6bed233
parentfb60c49d18d1d52b6b81680586754168bc3ebc2c
fetch-pack: drop the static advertise_sid variable

write_fetch_command_and_capabilities() is moved to 'connect.c' in a
subsequent commit. To prepare for that, drop the static variable usage
of advertise_sid.

Currently advertise_sid is set in fetch_pack_config() by reading
"transfer.advertisesid". It is used in three places:

1. In do_fetch_pack(), to clear it when the server lacks support:

        if (!server_supports("session-id"))
               advertise_sid = 0;

2. In find_common(), to advertise the session id over protocol v0/v1:

        if (advertise_sid)
                strbuf_addf(&c, " session-id=%s", trace2_session_id());

3. In write_fetch_command_and_capabilities(), to advertise it over
   protocol v2:

        if (advertise_sid && server_supports_v2("session-id"))
                packet_buf_write(req_buf, "session-id=%s", trace2_session_id());

About 1, the check only guards the v0/v1 path, and the v2 path
already checks server support inline in its condition. Follow the
same pattern and fold the check into the condition in find_common().

About 2 and 3, replace the static variable with a local read via
repo_config_get_bool() in each function.

Because repo_config_get_bool() leaves advertise_sid as is if it is not
set, initialize it to 0, matching its default.

Helped-by: Jonathan Tan <redacted>
Helped-by: Christian Couder <redacted>
Signed-off-by: Calvin Wan <redacted>
Signed-off-by: Eric Ju <redacted>
Signed-off-by: Pablo Sabater <redacted>
Signed-off-by: Junio C Hamano <redacted>
fetch-pack.c
git clone https://git.99rst.org/PROJECT