Git fork

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>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
cba3c025 627d08cc

+19 -24
+1 -1
builtin/fetch.c
··· 2508 2508 if (!max_jobs) 2509 2509 max_jobs = online_cpus(); 2510 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 2512 fetch_bundle_uri(the_repository, bundle_uri, NULL)) 2513 2513 warning(_("failed to fetch bundles from '%s'"), bundle_uri); 2514 2514
+2 -2
builtin/gc.c
··· 1765 1765 if (opts->schedule) { 1766 1766 strategy = none_strategy; 1767 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 1769 if (!strcasecmp(config_str, "incremental")) 1770 1770 strategy = incremental_strategy; 1771 1771 } ··· 1788 1788 strbuf_reset(&config_name); 1789 1789 strbuf_addf(&config_name, "maintenance.%s.schedule", 1790 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 1792 strategy.tasks[i].schedule = parse_schedule(config_str); 1793 1793 if (strategy.tasks[i].schedule < opts->schedule) 1794 1794 continue;
+1 -1
builtin/remote.c
··· 1268 1268 1269 1269 strbuf_addf(&promisor_config, "remote.%s.partialclonefilter", remote->name); 1270 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 1272 strbuf_addf(&remote_info_buf, " [%s]", partial_clone_filter); 1273 1273 1274 1274 strbuf_release(&promisor_config);
+2 -2
builtin/submodule--helper.c
··· 496 496 497 497 /* Copy "update" setting when it is not set yet */ 498 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 500 sub->update_strategy.type != SM_UPDATE_UNSPECIFIED) { 501 501 if (sub->update_strategy.type == SM_UPDATE_COMMAND) { 502 502 fprintf(stderr, _("warning: command update mode suggested for submodule '%s'\n"), ··· 1034 1034 1035 1035 config_key = xstrfmt("submodule.%s.ignore", 1036 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 1038 ignore_all = !strcmp(value, "all"); 1039 1039 else if (sub->ignore) 1040 1040 ignore_all = !strcmp(sub->ignore, "all");
+1 -1
checkout.c
··· 52 52 { 53 53 struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT; 54 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 56 cb_data.default_remote = default_remote; 57 57 cb_data.src_ref = xstrfmt("refs/heads/%s", name); 58 58 cb_data.dst_oid = oid;
-5
config.h
··· 719 719 int lookup_config(const char **mapping, int nr_mapping, const char *var); 720 720 721 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 - 727 722 static inline int git_config_get_int(const char *key, int *dest) 728 723 { 729 724 return repo_config_get_int(the_repository, key, dest);
+2 -2
connect.c
··· 1154 1154 if ((ssh = getenv("GIT_SSH_COMMAND"))) 1155 1155 return ssh; 1156 1156 1157 - if (!git_config_get_string_tmp("core.sshcommand", &ssh)) 1157 + if (!repo_config_get_string_tmp(the_repository, "core.sshcommand", &ssh)) 1158 1158 return ssh; 1159 1159 1160 1160 return NULL; ··· 1173 1173 { 1174 1174 const char *variant = getenv("GIT_SSH_VARIANT"); 1175 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 1177 return; 1178 1178 1179 1179 if (!strcmp(variant, "auto"))
+1 -1
editor.c
··· 50 50 const char *editor = getenv("GIT_SEQUENCE_EDITOR"); 51 51 52 52 if (!editor) 53 - git_config_get_string_tmp("sequence.editor", &editor); 53 + repo_config_get_string_tmp(the_repository, "sequence.editor", &editor); 54 54 if (!editor) 55 55 editor = git_editor(); 56 56
+1 -1
help.c
··· 417 417 { 418 418 const char *cmd_list; 419 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 421 return; 422 422 423 423 string_list_sort(list);
+2 -2
promisor-remote.c
··· 327 327 char *url_key = xstrfmt("remote.%s.url", r->name); 328 328 329 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 331 strvec_push(names, r->name); 332 332 strvec_push(urls, url); 333 333 } ··· 433 433 struct strvec names = STRVEC_INIT; 434 434 struct strvec urls = STRVEC_INIT; 435 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 437 if (!*accept_str || !strcasecmp("None", accept_str)) 438 438 accept = ACCEPT_NONE; 439 439 else if (!strcasecmp("KnownUrl", accept_str))
+1 -1
protocol.c
··· 24 24 const char *git_test_k = "GIT_TEST_PROTOCOL_VERSION"; 25 25 const char *git_test_v; 26 26 27 - if (!git_config_get_string_tmp("protocol.version", &value)) { 27 + if (!repo_config_get_string_tmp(the_repository, "protocol.version", &value)) { 28 28 enum protocol_version version = parse_protocol_version(value); 29 29 30 30 if (version == protocol_unknown_version)
+1 -1
remote.c
··· 734 734 struct strbuf redacted = STRBUF_INIT; 735 735 int warn_not_die; 736 736 737 - if (git_config_get_string_tmp("transfer.credentialsinurl", &value)) 737 + if (repo_config_get_string_tmp(the_repository, "transfer.credentialsinurl", &value)) 738 738 return; 739 739 740 740 if (!strcmp("warn", value))
+3 -3
sideband.c
··· 39 39 if (use_sideband_colors_cached >= 0) 40 40 return use_sideband_colors_cached; 41 41 42 - if (!git_config_get_string_tmp(key, &value)) 42 + if (!repo_config_get_string_tmp(the_repository, key, &value)) 43 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 45 use_sideband_colors_cached = git_config_colorbool("color.ui", value); 46 46 else 47 47 use_sideband_colors_cached = GIT_COLOR_AUTO; ··· 49 49 for (i = 0; i < ARRAY_SIZE(keywords); i++) { 50 50 strbuf_reset(&sb); 51 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 53 continue; 54 54 color_parse(value, keywords[i].color); 55 55 }
+1 -1
t/helper/test-config.c
··· 171 171 goto exit1; 172 172 } 173 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 175 printf("%s\n", v); 176 176 goto exit0; 177 177 } else {