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 627d08cca769999a7a9419b8aeaba26f61f551f5
12 files changed +25 -30
apply.c
+2 -2
@@ -48,8 +48,8 @@ struct gitdiff_data {
48
49 static void git_apply_config(void)
50 {
51 - git_config_get_string("apply.whitespace", &apply_default_whitespace);
52 - git_config_get_string("apply.ignorewhitespace", &apply_default_ignorewhitespace);
51 + repo_config_get_string(the_repository, "apply.whitespace", &apply_default_whitespace);
52 + repo_config_get_string(the_repository, "apply.ignorewhitespace", &apply_default_ignorewhitespace);
53 repo_config(the_repository, git_xmerge_config, NULL);
54 }
55
branch.c
+1 -1
@@ -355,7 +355,7 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
355 char *v = NULL;
356 struct strbuf name = STRBUF_INIT;
357 strbuf_addf(&name, "branch.%s.description", branch_name);
358 - if (git_config_get_string(name.buf, &v)) {
358 + if (repo_config_get_string(the_repository, name.buf, &v)) {
359 strbuf_release(&name);
360 return -1;
361 }
builtin/gc.c
+2 -2
@@ -218,12 +218,12 @@ static void gc_config(struct gc_config *cfg)
218 if (!git_config_get_ulong("core.deltabasecachelimit", &ulongval))
219 cfg->delta_base_cache_limit = ulongval;
220
221 - if (!git_config_get_string("gc.repackfilter", &owned)) {
221 + if (!repo_config_get_string(the_repository, "gc.repackfilter", &owned)) {
222 free(cfg->repack_filter);
223 cfg->repack_filter = owned;
224 }
225
226 - if (!git_config_get_string("gc.repackfilterto", &owned)) {
226 + if (!repo_config_get_string(the_repository, "gc.repackfilterto", &owned)) {
227 free(cfg->repack_filter_to);
228 cfg->repack_filter_to = owned;
229 }
builtin/log.c
+1 -1
@@ -235,7 +235,7 @@ static void set_default_decoration_filter(struct decoration_filter *decoration_f
235 * since the command-line takes precedent.
236 */
237 if (use_default_decoration_filter &&
238 - !git_config_get_string("log.initialdecorationset", &value) &&
238 + !repo_config_get_string(the_repository, "log.initialdecorationset", &value) &&
239 !strcmp("all", value))
240 use_default_decoration_filter = 0;
241 free(value);
builtin/notes.c
+1 -1
@@ -873,7 +873,7 @@ static int git_config_get_notes_strategy(const char *key,
873 {
874 char *value;
875
876 - if (git_config_get_string(key, &value))
876 + if (repo_config_get_string(the_repository, key, &value))
877 return 1;
878 if (parse_notes_merge_strategy(value, strategy))
879 git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);
builtin/submodule--helper.c
+6 -6
@@ -53,7 +53,7 @@ static char *resolve_relative_url(const char *rel_url, const char *up_path, int
53 struct strbuf remotesb = STRBUF_INIT;
54
55 strbuf_addf(&remotesb, "remote.%s.url", remote);
56 - if (git_config_get_string(remotesb.buf, &remoteurl)) {
56 + if (repo_config_get_string(the_repository, remotesb.buf, &remoteurl)) {
57 if (!quiet)
58 warning(_("could not look up configuration '%s'. "
59 "Assuming this repository is its own "
@@ -468,7 +468,7 @@ static void init_submodule(const char *path, const char *prefix,
468 * .gitmodules, so look it up directly.
469 */
470 strbuf_addf(&sb, "submodule.%s.url", sub->name);
471 - if (git_config_get_string(sb.buf, &url)) {
471 + if (repo_config_get_string(the_repository, sb.buf, &url)) {
472 if (!sub->url)
473 die(_("No url found for submodule path '%s' in .gitmodules"),
474 displaypath);
@@ -1623,11 +1623,11 @@ static void prepare_possible_alternates(const char *sm_name,
1623 char *sm_alternate = NULL, *error_strategy = NULL;
1624 struct submodule_alternate_setup sas = SUBMODULE_ALTERNATE_SETUP_INIT;
1625
1626 - git_config_get_string("submodule.alternateLocation", &sm_alternate);
1626 + repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
1627 if (!sm_alternate)
1628 return;
1629
1630 - git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
1630 + repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
1631
1632 if (!error_strategy)
1633 error_strategy = xstrdup("die");
@@ -1808,11 +1808,11 @@ static int clone_submodule(const struct module_clone_data *clone_data,
1808 die(_("could not get submodule directory for '%s'"), clone_data_path);
1809
1810 /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
1811 - git_config_get_string("submodule.alternateLocation", &sm_alternate);
1811 + repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
1812 if (sm_alternate)
1813 git_config_set_in_file(p, "submodule.alternateLocation",
1814 sm_alternate);
1815 - git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
1815 + repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
1816 if (error_strategy)
1817 git_config_set_in_file(p, "submodule.alternateErrorStrategy",
1818 error_strategy);
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(const char *key, char **dest)
723 -{
724 - return repo_config_get_string(the_repository, key, dest);
725 -}
726 -
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);
fetch-pack.c
+1 -1
@@ -1910,7 +1910,7 @@ static void fetch_pack_config(void)
1910 if (!uri_protocols.nr) {
1911 char *str;
1912
1913 - if (!git_config_get_string("fetch.uriprotocols", &str) && str) {
1913 + if (!repo_config_get_string(the_repository, "fetch.uriprotocols", &str) && str) {
1914 string_list_split(&uri_protocols, str, ',', -1);
1915 free(str);
1916 }
merge-ort.c
+4 -4
@@ -5358,15 +5358,15 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
5358 git_config_get_int("merge.renamelimit", &opt->rename_limit);
5359 git_config_get_bool("merge.renormalize", &renormalize);
5360 opt->renormalize = renormalize;
5361 - if (!git_config_get_string("diff.renames", &value)) {
5361 + if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
5362 opt->detect_renames = git_config_rename("diff.renames", value);
5363 free(value);
5364 }
5365 - if (!git_config_get_string("merge.renames", &value)) {
5365 + if (!repo_config_get_string(the_repository, "merge.renames", &value)) {
5366 opt->detect_renames = git_config_rename("merge.renames", value);
5367 free(value);
5368 }
5369 - if (!git_config_get_string("merge.directoryrenames", &value)) {
5369 + if (!repo_config_get_string(the_repository, "merge.directoryrenames", &value)) {
5370 int boolval = git_parse_maybe_bool(value);
5371 if (0 <= boolval) {
5372 opt->detect_directory_renames = boolval ?
@@ -5379,7 +5379,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
5379 free(value);
5380 }
5381 if (ui) {
5382 - if (!git_config_get_string("diff.algorithm", &value)) {
5382 + if (!repo_config_get_string(the_repository, "diff.algorithm", &value)) {
5383 long diff_algorithm = parse_algorithm_value(value);
5384 if (diff_algorithm < 0)
5385 die(_("unknown value for config '%s': %s"), "diff.algorithm", value);
scalar.c
+2 -2
@@ -101,7 +101,7 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
101 int res;
102
103 if ((reconfigure && config->overwrite_on_reconfigure) ||
104 - git_config_get_string(config->key, &value)) {
104 + repo_config_get_string(the_repository, config->key, &value)) {
105 trace2_data_string("scalar", the_repository, config->key, "created");
106 res = git_config_set_gently(config->key, config->value);
107 } else {
@@ -193,7 +193,7 @@ static int set_recommended_config(int reconfigure)
193 * The `log.excludeDecoration` setting is special because it allows
194 * for multiple values.
195 */
196 - if (git_config_get_string("log.excludeDecoration", &value)) {
196 + if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) {
197 trace2_data_string("scalar", the_repository,
198 "log.excludeDecoration", "created");
199 if (git_config_set_multivar_gently("log.excludeDecoration",
sequencer.c
+1 -1
@@ -6089,7 +6089,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
6089 revs.topo_order = 1;
6090
6091 revs.pretty_given = 1;
6092 - git_config_get_string("rebase.instructionFormat", &format);
6092 + repo_config_get_string(the_repository, "rebase.instructionFormat", &format);
6093 if (!format || !*format) {
6094 free(format);
6095 format = xstrdup("# %s");
transport.c
+4 -4
@@ -54,14 +54,14 @@ static int transport_color_config(void)
54 return 0;
55 initialized = 1;
56
57 - if (!git_config_get_string(key, &value))
57 + if (!repo_config_get_string(the_repository, key, &value))
58 transport_use_color = git_config_colorbool(key, value);
59
60 if (!want_color_stderr(transport_use_color))
61 return 0;
62
63 for (size_t i = 0; i < ARRAY_SIZE(keys); i++)
64 - if (!git_config_get_string(keys[i], &value)) {
64 + if (!repo_config_get_string(the_repository, keys[i], &value)) {
65 if (!value)
66 return config_error_nonbool(keys[i]);
67 if (color_parse(value, transport_colors[i]) < 0)
@@ -1078,7 +1078,7 @@ static enum protocol_allow_config get_protocol_config(const char *type)
1078 char *value;
1079
1080 /* first check the per-protocol config */
1081 - if (!git_config_get_string(key, &value)) {
1081 + if (!repo_config_get_string(the_repository, key, &value)) {
1082 enum protocol_allow_config ret =
1083 parse_protocol_config(key, value);
1084 free(key);
@@ -1088,7 +1088,7 @@ static enum protocol_allow_config get_protocol_config(const char *type)
1088 free(key);
1089
1090 /* if defined, fallback to user-defined default for unknown protocols */
1091 - if (!git_config_get_string("protocol.allow", &value)) {
1091 + if (!repo_config_get_string(the_repository, "protocol.allow", &value)) {
1092 enum protocol_allow_config ret =
1093 parse_protocol_config("protocol.allow", value);
1094 free(value);