config: drop `git_config_get_string()` wrapper

In 036876a1067 (config: hide functions using `the_repository` by default, 2024-08-13) we have moved around a bunch of functions in the config subsystem that depend on `the_repository`. Those function have been converted into mere wrappers around their equivalent function that takes in a repository as parameter, and the intent was that we'll eventually remove those wrappers to make the dependency on the global repository variable explicit at the callsite. Follow through with that intent and remove `git_config_get_string()`. All callsites are adjusted so that they use `repo_config_get_string(the_repository, ...)` instead. While some callsites might already have a repository available, this mechanical conversion is the exact same as the current situation and thus cannot cause any regression. Those sites should eventually be cleaned up in a later patch series. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Jul 23, 2025 at 16:08 UTC cba3c02591b820fdb812cb2c2ebb5dbd98761ba8
14 files changed +19 -24
builtin/fetch.c
+1 -1
@@ -2508,7 +2508,7 @@ int cmd_fetch(int argc,
2508 if (!max_jobs)
2509 max_jobs = online_cpus();
2510
2511 - if (!git_config_get_string_tmp("fetch.bundleuri", &bundle_uri) &&
2511 + if (!repo_config_get_string_tmp(the_repository, "fetch.bundleuri", &bundle_uri) &&
2512 fetch_bundle_uri(the_repository, bundle_uri, NULL))
2513 warning(_("failed to fetch bundles from '%s'"), bundle_uri);
2514
builtin/gc.c
+2 -2
@@ -1765,7 +1765,7 @@ static void initialize_task_config(struct maintenance_run_opts *opts,
1765 if (opts->schedule) {
1766 strategy = none_strategy;
1767
1768 - if (!git_config_get_string_tmp("maintenance.strategy", &config_str)) {
1768 + if (!repo_config_get_string_tmp(the_repository, "maintenance.strategy", &config_str)) {
1769 if (!strcasecmp(config_str, "incremental"))
1770 strategy = incremental_strategy;
1771 }
@@ -1788,7 +1788,7 @@ static void initialize_task_config(struct maintenance_run_opts *opts,
1788 strbuf_reset(&config_name);
1789 strbuf_addf(&config_name, "maintenance.%s.schedule",
1790 tasks[i].name);
1791 - if (!git_config_get_string_tmp(config_name.buf, &config_str))
1791 + if (!repo_config_get_string_tmp(the_repository, config_name.buf, &config_str))
1792 strategy.tasks[i].schedule = parse_schedule(config_str);
1793 if (strategy.tasks[i].schedule < opts->schedule)
1794 continue;
builtin/remote.c
+1 -1
@@ -1268,7 +1268,7 @@ static int get_one_entry(struct remote *remote, void *priv)
1268
1269 strbuf_addf(&promisor_config, "remote.%s.partialclonefilter", remote->name);
1270 strbuf_addf(&remote_info_buf, "%s (fetch)", remote->url.v[0]);
1271 - if (!git_config_get_string_tmp(promisor_config.buf, &partial_clone_filter))
1271 + if (!repo_config_get_string_tmp(the_repository, promisor_config.buf, &partial_clone_filter))
1272 strbuf_addf(&remote_info_buf, " [%s]", partial_clone_filter);
1273
1274 strbuf_release(&promisor_config);
builtin/submodule--helper.c
+2 -2
@@ -496,7 +496,7 @@ static void init_submodule(const char *path, const char *prefix,
496
497 /* Copy "update" setting when it is not set yet */
498 strbuf_addf(&sb, "submodule.%s.update", sub->name);
499 - if (git_config_get_string_tmp(sb.buf, &upd) &&
499 + if (repo_config_get_string_tmp(the_repository, sb.buf, &upd) &&
500 sub->update_strategy.type != SM_UPDATE_UNSPECIFIED) {
501 if (sub->update_strategy.type == SM_UPDATE_COMMAND) {
502 fprintf(stderr, _("warning: command update mode suggested for submodule '%s'\n"),
@@ -1034,7 +1034,7 @@ static void prepare_submodule_summary(struct summary_cb *info,
1034
1035 config_key = xstrfmt("submodule.%s.ignore",
1036 sub->name);
1037 - if (!git_config_get_string_tmp(config_key, &value))
1037 + if (!repo_config_get_string_tmp(the_repository, config_key, &value))
1038 ignore_all = !strcmp(value, "all");
1039 else if (sub->ignore)
1040 ignore_all = !strcmp(sub->ignore, "all");
checkout.c
+1 -1
@@ -52,7 +52,7 @@ char *unique_tracking_name(const char *name, struct object_id *oid,
52 {
53 struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;
54 const char *default_remote = NULL;
55 - if (!git_config_get_string_tmp("checkout.defaultremote", &default_remote))
55 + if (!repo_config_get_string_tmp(the_repository, "checkout.defaultremote", &default_remote))
56 cb_data.default_remote = default_remote;
57 cb_data.src_ref = xstrfmt("refs/heads/%s", name);
58 cb_data.dst_oid = oid;
config.h
-5
@@ -719,11 +719,6 @@ NORETURN void git_die_config_linenr(const char *key, const char *filename, int l
719 int lookup_config(const char **mapping, int nr_mapping, const char *var);
720
721 # ifdef USE_THE_REPOSITORY_VARIABLE
722 -static inline int git_config_get_string_tmp(const char *key, const char **dest)
723 -{
724 - return repo_config_get_string_tmp(the_repository, key, dest);
725 -}
726 -
722 static inline int git_config_get_int(const char *key, int *dest)
723 {
724 return repo_config_get_int(the_repository, key, dest);
connect.c
+2 -2
@@ -1154,7 +1154,7 @@ static const char *get_ssh_command(void)
1154 if ((ssh = getenv("GIT_SSH_COMMAND")))
1155 return ssh;
1156
1157 - if (!git_config_get_string_tmp("core.sshcommand", &ssh))
1157 + if (!repo_config_get_string_tmp(the_repository, "core.sshcommand", &ssh))
1158 return ssh;
1159
1160 return NULL;
@@ -1173,7 +1173,7 @@ static void override_ssh_variant(enum ssh_variant *ssh_variant)
1173 {
1174 const char *variant = getenv("GIT_SSH_VARIANT");
1175
1176 - if (!variant && git_config_get_string_tmp("ssh.variant", &variant))
1176 + if (!variant && repo_config_get_string_tmp(the_repository, "ssh.variant", &variant))
1177 return;
1178
1179 if (!strcmp(variant, "auto"))
editor.c
+1 -1
@@ -50,7 +50,7 @@ const char *git_sequence_editor(void)
50 const char *editor = getenv("GIT_SEQUENCE_EDITOR");
51
52 if (!editor)
53 - git_config_get_string_tmp("sequence.editor", &editor);
53 + repo_config_get_string_tmp(the_repository, "sequence.editor", &editor);
54 if (!editor)
55 editor = git_editor();
56
help.c
+1 -1
@@ -417,7 +417,7 @@ void list_cmds_by_config(struct string_list *list)
417 {
418 const char *cmd_list;
419
420 - if (git_config_get_string_tmp("completion.commands", &cmd_list))
420 + if (repo_config_get_string_tmp(the_repository, "completion.commands", &cmd_list))
421 return;
422
423 string_list_sort(list);
promisor-remote.c
+2 -2
@@ -327,7 +327,7 @@ static void promisor_info_vecs(struct repository *repo,
327 char *url_key = xstrfmt("remote.%s.url", r->name);
328
329 /* Only add remotes with a non empty URL */
330 - if (!git_config_get_string_tmp(url_key, &url) && *url) {
330 + if (!repo_config_get_string_tmp(the_repository, url_key, &url) && *url) {
331 strvec_push(names, r->name);
332 strvec_push(urls, url);
333 }
@@ -433,7 +433,7 @@ static void filter_promisor_remote(struct repository *repo,
433 struct strvec names = STRVEC_INIT;
434 struct strvec urls = STRVEC_INIT;
435
436 - if (!git_config_get_string_tmp("promisor.acceptfromserver", &accept_str)) {
436 + if (!repo_config_get_string_tmp(the_repository, "promisor.acceptfromserver", &accept_str)) {
437 if (!*accept_str || !strcasecmp("None", accept_str))
438 accept = ACCEPT_NONE;
439 else if (!strcasecmp("KnownUrl", accept_str))
protocol.c
+1 -1
@@ -24,7 +24,7 @@ enum protocol_version get_protocol_version_config(void)
24 const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION";
25 const char *git_test_v;
26
27 - if (!git_config_get_string_tmp("protocol.version", &value)) {
27 + if (!repo_config_get_string_tmp(the_repository, "protocol.version", &value)) {
28 enum protocol_version version = parse_protocol_version(value);
29
30 if (version == protocol_unknown_version)
remote.c
+1 -1
@@ -734,7 +734,7 @@ static void validate_remote_url(struct remote *remote)
734 struct strbuf redacted = STRBUF_INIT;
735 int warn_not_die;
736
737 - if (git_config_get_string_tmp("transfer.credentialsinurl", &value))
737 + if (repo_config_get_string_tmp(the_repository, "transfer.credentialsinurl", &value))
738 return;
739
740 if (!strcmp("warn", value))
sideband.c
+3 -3
@@ -39,9 +39,9 @@ static int use_sideband_colors(void)
39 if (use_sideband_colors_cached >= 0)
40 return use_sideband_colors_cached;
41
42 - if (!git_config_get_string_tmp(key, &value))
42 + if (!repo_config_get_string_tmp(the_repository, key, &value))
43 use_sideband_colors_cached = git_config_colorbool(key, value);
44 - else if (!git_config_get_string_tmp("color.ui", &value))
44 + else if (!repo_config_get_string_tmp(the_repository, "color.ui", &value))
45 use_sideband_colors_cached = git_config_colorbool("color.ui", value);
46 else
47 use_sideband_colors_cached = GIT_COLOR_AUTO;
@@ -49,7 +49,7 @@ static int use_sideband_colors(void)
49 for (i = 0; i < ARRAY_SIZE(keywords); i++) {
50 strbuf_reset(&sb);
51 strbuf_addf(&sb, "%s.%s", key, keywords[i].keyword);
52 - if (git_config_get_string_tmp(sb.buf, &value))
52 + if (repo_config_get_string_tmp(the_repository, sb.buf, &value))
53 continue;
54 color_parse(value, keywords[i].color);
55 }
t/helper/test-config.c
+1 -1
@@ -171,7 +171,7 @@ int cmd__config(int argc, const char **argv)
171 goto exit1;
172 }
173 } else if (argc == 3 && !strcmp(argv[1], "get_string")) {
174 - if (!git_config_get_string_tmp(argv[2], &v)) {
174 + if (!repo_config_get_string_tmp(the_repository, argv[2], &v)) {
175 printf("%s\n", v);
176 goto exit0;
177 } else {