]> git.ipfire.org Git - thirdparty/git.git/commitdiff
upload-pack: centralize setup of sideband-all config
authorJeff King <peff@peff.net>
Wed, 28 Feb 2024 22:47:18 +0000 (17:47 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Feb 2024 23:30:41 +0000 (15:30 -0800)
We read uploadpack.allowsidebandall to set a matching flag in our
upload_pack_data struct. But for our tests, we also respect
GIT_TEST_SIDEBAND_ALL from the environment, and anybody looking at the
flag in the struct needs to remember to check both. There's only one
such piece of code now, but we're about to add another.

So let's have the config step actually fold the environment value into
the struct, letting the rest of the code use the flag in the obvious
way.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c

index e156c1e47257abbeb769672b387787f9469b4e28..6bda20754d0977a98e3983fc7f8bb97b23b58a70 100644 (file)
@@ -1390,6 +1390,8 @@ static void get_upload_pack_config(struct repository *r,
 {
        repo_config(r, upload_pack_config, data);
        git_protected_config(upload_pack_protected_config, data);
+
+       data->allow_sideband_all |= git_env_bool("GIT_TEST_SIDEBAND_ALL", 0);
 }
 
 void upload_pack(const int advertise_refs, const int stateless_rpc,
@@ -1639,8 +1641,7 @@ static void process_args(struct packet_reader *request,
                        continue;
                }
 
-               if ((git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) ||
-                    data->allow_sideband_all) &&
+               if (data->allow_sideband_all &&
                    !strcmp(arg, "sideband-all")) {
                        data->writer.use_sideband = 1;
                        continue;