upload-pack: use repository struct to get config

Our upload_pack_v2() function gets a repository struct, but we ignore it totally. In practice this doesn't cause any problems, as it will never differ from the_repository. But in the spirit of taking a small step towards getting rid of the_repository, let's at least starting using it to grab config. There are probably other spots that could benefit, but it's a start. Note that we don't need to pass the repo for protected_config(); the whole point there is that we are not looking at repo config, so there is no repo-specific version of the function. For the v0 version of the protocol, we're not passed a repository struct, so we'll continue to use the_repository there. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 28, 2024 at 17:46 UTC 922fdefb84c4341c0bb10f3ca090725f9fcc8bcb
1 file changed +6 -5
upload-pack.c
+6 -5
@@ -1385,9 +1385,10 @@ static int upload_pack_protected_config(const char *var, const char *value,
1385 return 0;
1386 }
1387
1388 -static void get_upload_pack_config(struct upload_pack_data *data)
1388 +static void get_upload_pack_config(struct repository *r,
1389 + struct upload_pack_data *data)
1390 {
1390 - git_config(upload_pack_config, data);
1391 + repo_config(r, upload_pack_config, data);
1392 git_protected_config(upload_pack_protected_config, data);
1393 }
1394
@@ -1398,7 +1399,7 @@ void upload_pack(const int advertise_refs, const int stateless_rpc,
1399 struct upload_pack_data data;
1400
1401 upload_pack_data_init(&data);
1401 - get_upload_pack_config(&data);
1402 + get_upload_pack_config(the_repository, &data);
1403
1404 data.stateless_rpc = stateless_rpc;
1405 data.timeout = timeout;
@@ -1771,7 +1772,7 @@ enum fetch_state {
1772 FETCH_DONE,
1773 };
1774
1774 -int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request)
1775 +int upload_pack_v2(struct repository *r, struct packet_reader *request)
1776 {
1777 enum fetch_state state = FETCH_PROCESS_ARGS;
1778 struct upload_pack_data data;
@@ -1780,7 +1781,7 @@ int upload_pack_v2(struct repository *r UNUSED, struct packet_reader *request)
1781
1782 upload_pack_data_init(&data);
1783 data.use_sideband = LARGE_PACKET_MAX;
1783 - get_upload_pack_config(&data);
1784 + get_upload_pack_config(r, &data);
1785
1786 while (state != FETCH_DONE) {
1787 switch (state) {