summaryrefslogtreecommitdiff
path: root/serve.c
diff options
context:
space:
mode:
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>2021-08-05 01:25:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-08-05 15:59:37 (GMT)
commiteea7f7a977c61f313774d591ed54ec9d7345fdaf (patch)
tree5d6b8151cf43c77d542a4e02e78d23a75e9eada4 /serve.c
parent28a592e4f4870bdd444675b7240920d0879a9c1b (diff)
downloadgit-eea7f7a977c61f313774d591ed54ec9d7345fdaf.zip
git-eea7f7a977c61f313774d591ed54ec9d7345fdaf.tar.gz
git-eea7f7a977c61f313774d591ed54ec9d7345fdaf.tar.bz2
serve: move transfer.advertiseSID check into session_id_advertise()
In 6b5b6e422ee (serve: advertise session ID in v2 capabilities, 2020-11-11) the check for transfer.advertiseSID was added to the beginning of the main serve() loop. Thus on startup of the server we'd populate it. Let's instead use an explicit lazy initialization pattern in session_id_advertise() itself, we'll still look the config up only once per-process, but by moving it out of serve() itself the further changing of that routine becomes easier. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'serve.c')
-rw-r--r--serve.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/serve.c b/serve.c
index 967bf17..2682999 100644
--- a/serve.c
+++ b/serve.c
@@ -9,7 +9,7 @@
#include "serve.h"
#include "upload-pack.h"
-static int advertise_sid;
+static int advertise_sid = -1;
static int always_advertise(struct repository *r,
struct strbuf *value)
@@ -35,6 +35,9 @@ static int object_format_advertise(struct repository *r,
static int session_id_advertise(struct repository *r, struct strbuf *value)
{
+ if (advertise_sid == -1 &&
+ git_config_get_bool("transfer.advertisesid", &advertise_sid))
+ advertise_sid = 0;
if (!advertise_sid)
return 0;
if (value)
@@ -300,8 +303,6 @@ static int process_request(void)
/* Main serve loop for protocol version 2 */
void serve(struct serve_options *options)
{
- git_config_get_bool("transfer.advertisesid", &advertise_sid);
-
if (options->advertise_capabilities || !options->stateless_rpc) {
/* serve by default supports v2 */
packet_write_fmt(1, "version 2\n");