From: Christian Couder Date: Mon, 27 Apr 2026 12:44:45 GMT Subject: Re: [PATCH 13/16] promisor-remote: introduce promisor.acceptFromServerUrl Message-ID: In-Reply-To: On Thu, Mar 26, 2026 at 1:21 PM Patrick Steinhardt wrote: > > On Mon, Mar 23, 2026 at 09:05:16AM +0100, Christian Couder wrote: > > diff --git a/promisor-remote.c b/promisor-remote.c > > index c2f0eb7223..4cb18e1a6a 100644 > > --- a/promisor-remote.c > > +++ b/promisor-remote.c > [snip] > > +static struct string_list *accept_from_server_url(struct repository *repo) > > +{ > > + static struct string_list accept_urls = STRING_LIST_INIT_DUP; > > + static int initialized; > > + const struct string_list *config_urls; > > + > > + if (initialized) > > + return &accept_urls; > > + > > + initialized = 1; > > + > > + if (!repo_config_get_string_multi(repo, "promisor.acceptfromserverurl", &config_urls)) { > > + struct string_list_item *item; > > + > > + for_each_string_list_item(item, config_urls) { > > + struct allowed_url *allowed = valid_accept_url(item->string); > > + if (allowed) { > > + struct string_list_item *new; > > + new = string_list_append(&accept_urls, item->string); > > + new->util = allowed; > > + } > > + } > > + } > > + > > + return &accept_urls; > > +} > > I'm still not much of a fan of us getting more and more function-local > static variables. It just feels wrong to me, and like we're accruing > technical debt. I also doubt that the performance overhead of storing > this on the stack with proper lifecycle management will matter at all > given that we're in a context where we talk with a remote anyway. The > handful of allocations really shouldn't matter in that context. OK, I have removed the static variables and it looks like the following in v2: +static void load_accept_from_server_url(struct repository *repo, + struct string_list *accept_urls) +{ + const struct string_list *config_urls; + + if (!repo_config_get_string_multi(repo, "promisor.acceptfromserverurl", &config_urls)) { + struct string_list_item *item; + + for_each_string_list_item(item, config_urls) { + struct allowed_url *allowed = valid_accept_url(item->string); + if (allowed) { + struct string_list_item *new; + new = string_list_append(accept_urls, item->string); + new->util = allowed; + } + } + } +} + static int should_accept_remote(enum accept_promisor accept, struct promisor_info *advertised, struct string_list *config_info) @@ -901,6 +986,10 @@ static void filter_promisor_remote(struct repository *repo, struct string_list_item *item; bool reload_config = false; enum accept_promisor accept = accept_from_server(repo); + struct string_list accept_urls = STRING_LIST_INIT_DUP; + + /* Load and validate the acceptFromServerUrl config */ + load_accept_from_server_url(repo, &accept_urls); if (accept == ACCEPT_NONE) return;