serve: use repository pointer to get config

A few of the v2 "serve" callbacks ignore their repository parameter and read config using the_repository (either directly or implicitly by calling wrapper functions). This isn't a bug since the server code only handles a single main repository anyway (and indeed, if you look at the callers, these repository parameters will always be the_repository). But in the long run we want to get rid of the_repository, so let's take a tiny step in that direction. As a bonus, this silences some -Wunused-parameter warnings. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Feb 24, 2023 at 01:38 UTC 4b4e75dd4f1dac0c25bded7466b0cc20c9649efb
4 files changed +10 -10
bundle-uri.c
+1 -1
@@ -884,7 +884,7 @@ int bundle_uri_command(struct repository *r,
884 * Read all "bundle.*" config lines to the client as key=value
885 * packet lines.
886 */
887 - git_config(config_to_packet_line, &writer);
887 + repo_config(r, config_to_packet_line, &writer);
888
889 packet_writer_flush(&writer);
890
ls-refs.c
+4 -4
@@ -12,11 +12,11 @@ static enum {
12 UNBORN_IGNORE = 0,
13 UNBORN_ALLOW,
14 UNBORN_ADVERTISE /* implies ALLOW */
15 -} unborn_config(void)
15 +} unborn_config(struct repository *r)
16 {
17 const char *str = NULL;
18
19 - if (repo_config_get_string_tmp(the_repository, "lsrefs.unborn", &str)) {
19 + if (repo_config_get_string_tmp(r, "lsrefs.unborn", &str)) {
20 /*
21 * If there is no such config, advertise and allow it by
22 * default.
@@ -168,7 +168,7 @@ int ls_refs(struct repository *r, struct packet_reader *request)
168 strvec_push(&data.prefixes, out);
169 }
170 else if (!strcmp("unborn", arg))
171 - data.unborn = !!unborn_config();
171 + data.unborn = !!unborn_config(r);
172 else
173 die(_("unexpected line: '%s'"), arg);
174 }
@@ -199,7 +199,7 @@ int ls_refs(struct repository *r, struct packet_reader *request)
199
200 int ls_refs_advertise(struct repository *r, struct strbuf *value)
201 {
202 - if (value && unborn_config() == UNBORN_ADVERTISE)
202 + if (value && unborn_config(r) == UNBORN_ADVERTISE)
203 strbuf_addstr(value, "unborn");
204
205 return 1;
serve.c
+1 -1
@@ -48,7 +48,7 @@ static void object_format_receive(struct repository *r,
48 static int session_id_advertise(struct repository *r, struct strbuf *value)
49 {
50 if (advertise_sid == -1 &&
51 - git_config_get_bool("transfer.advertisesid", &advertise_sid))
51 + repo_config_get_bool(r, "transfer.advertisesid", &advertise_sid))
52 advertise_sid = 0;
53 if (!advertise_sid)
54 return 0;
upload-pack.c
+4 -4
@@ -1775,26 +1775,26 @@ int upload_pack_advertise(struct repository *r,
1775
1776 strbuf_addstr(value, "shallow wait-for-done");
1777
1778 - if (!repo_config_get_bool(the_repository,
1778 + if (!repo_config_get_bool(r,
1779 "uploadpack.allowfilter",
1780 &allow_filter_value) &&
1781 allow_filter_value)
1782 strbuf_addstr(value, " filter");
1783
1784 - if (!repo_config_get_bool(the_repository,
1784 + if (!repo_config_get_bool(r,
1785 "uploadpack.allowrefinwant",
1786 &allow_ref_in_want) &&
1787 allow_ref_in_want)
1788 strbuf_addstr(value, " ref-in-want");
1789
1790 if (git_env_bool("GIT_TEST_SIDEBAND_ALL", 0) ||
1791 - (!repo_config_get_bool(the_repository,
1791 + (!repo_config_get_bool(r,
1792 "uploadpack.allowsidebandall",
1793 &allow_sideband_all_value) &&
1794 allow_sideband_all_value))
1795 strbuf_addstr(value, " sideband-all");
1796
1797 - if (!repo_config_get_string(the_repository,
1797 + if (!repo_config_get_string(r,
1798 "uploadpack.blobpackfileuri",
1799 &str) &&
1800 str) {