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
627d08cc 4f5ba823

+25 -30
+2 -2
apply.c
··· 48 48 49 49 static void git_apply_config(void) 50 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 53 repo_config(the_repository, git_xmerge_config, NULL); 54 54 } 55 55
+1 -1
branch.c
··· 355 355 char *v = NULL; 356 356 struct strbuf name = STRBUF_INIT; 357 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 359 strbuf_release(&name); 360 360 return -1; 361 361 }
+2 -2
builtin/gc.c
··· 218 218 if (!git_config_get_ulong("core.deltabasecachelimit", &ulongval)) 219 219 cfg->delta_base_cache_limit = ulongval; 220 220 221 - if (!git_config_get_string("gc.repackfilter", &owned)) { 221 + if (!repo_config_get_string(the_repository, "gc.repackfilter", &owned)) { 222 222 free(cfg->repack_filter); 223 223 cfg->repack_filter = owned; 224 224 } 225 225 226 - if (!git_config_get_string("gc.repackfilterto", &owned)) { 226 + if (!repo_config_get_string(the_repository, "gc.repackfilterto", &owned)) { 227 227 free(cfg->repack_filter_to); 228 228 cfg->repack_filter_to = owned; 229 229 }
+1 -1
builtin/log.c
··· 235 235 * since the command-line takes precedent. 236 236 */ 237 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 239 !strcmp("all", value)) 240 240 use_default_decoration_filter = 0; 241 241 free(value);
+1 -1
builtin/notes.c
··· 873 873 { 874 874 char *value; 875 875 876 - if (git_config_get_string(key, &value)) 876 + if (repo_config_get_string(the_repository, key, &value)) 877 877 return 1; 878 878 if (parse_notes_merge_strategy(value, strategy)) 879 879 git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);
+6 -6
builtin/submodule--helper.c
··· 53 53 struct strbuf remotesb = STRBUF_INIT; 54 54 55 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 57 if (!quiet) 58 58 warning(_("could not look up configuration '%s'. " 59 59 "Assuming this repository is its own " ··· 468 468 * .gitmodules, so look it up directly. 469 469 */ 470 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 472 if (!sub->url) 473 473 die(_("No url found for submodule path '%s' in .gitmodules"), 474 474 displaypath); ··· 1623 1623 char *sm_alternate = NULL, *error_strategy = NULL; 1624 1624 struct submodule_alternate_setup sas = SUBMODULE_ALTERNATE_SETUP_INIT; 1625 1625 1626 - git_config_get_string("submodule.alternateLocation", &sm_alternate); 1626 + repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate); 1627 1627 if (!sm_alternate) 1628 1628 return; 1629 1629 1630 - git_config_get_string("submodule.alternateErrorStrategy", &error_strategy); 1630 + repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy); 1631 1631 1632 1632 if (!error_strategy) 1633 1633 error_strategy = xstrdup("die"); ··· 1808 1808 die(_("could not get submodule directory for '%s'"), clone_data_path); 1809 1809 1810 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 1812 if (sm_alternate) 1813 1813 git_config_set_in_file(p, "submodule.alternateLocation", 1814 1814 sm_alternate); 1815 - git_config_get_string("submodule.alternateErrorStrategy", &error_strategy); 1815 + repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy); 1816 1816 if (error_strategy) 1817 1817 git_config_set_in_file(p, "submodule.alternateErrorStrategy", 1818 1818 error_strategy);
-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(const char *key, char **dest) 723 - { 724 - return repo_config_get_string(the_repository, key, dest); 725 - } 726 - 727 722 static inline int git_config_get_string_tmp(const char *key, const char **dest) 728 723 { 729 724 return repo_config_get_string_tmp(the_repository, key, dest);
+1 -1
fetch-pack.c
··· 1910 1910 if (!uri_protocols.nr) { 1911 1911 char *str; 1912 1912 1913 - if (!git_config_get_string("fetch.uriprotocols", &str) && str) { 1913 + if (!repo_config_get_string(the_repository, "fetch.uriprotocols", &str) && str) { 1914 1914 string_list_split(&uri_protocols, str, ',', -1); 1915 1915 free(str); 1916 1916 }
+4 -4
merge-ort.c
··· 5358 5358 git_config_get_int("merge.renamelimit", &opt->rename_limit); 5359 5359 git_config_get_bool("merge.renormalize", &renormalize); 5360 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 5362 opt->detect_renames = git_config_rename("diff.renames", value); 5363 5363 free(value); 5364 5364 } 5365 - if (!git_config_get_string("merge.renames", &value)) { 5365 + if (!repo_config_get_string(the_repository, "merge.renames", &value)) { 5366 5366 opt->detect_renames = git_config_rename("merge.renames", value); 5367 5367 free(value); 5368 5368 } 5369 - if (!git_config_get_string("merge.directoryrenames", &value)) { 5369 + if (!repo_config_get_string(the_repository, "merge.directoryrenames", &value)) { 5370 5370 int boolval = git_parse_maybe_bool(value); 5371 5371 if (0 <= boolval) { 5372 5372 opt->detect_directory_renames = boolval ? ··· 5379 5379 free(value); 5380 5380 } 5381 5381 if (ui) { 5382 - if (!git_config_get_string("diff.algorithm", &value)) { 5382 + if (!repo_config_get_string(the_repository, "diff.algorithm", &value)) { 5383 5383 long diff_algorithm = parse_algorithm_value(value); 5384 5384 if (diff_algorithm < 0) 5385 5385 die(_("unknown value for config '%s': %s"), "diff.algorithm", value);
+2 -2
scalar.c
··· 101 101 int res; 102 102 103 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 105 trace2_data_string("scalar", the_repository, config->key, "created"); 106 106 res = git_config_set_gently(config->key, config->value); 107 107 } else { ··· 193 193 * The `log.excludeDecoration` setting is special because it allows 194 194 * for multiple values. 195 195 */ 196 - if (git_config_get_string("log.excludeDecoration", &value)) { 196 + if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) { 197 197 trace2_data_string("scalar", the_repository, 198 198 "log.excludeDecoration", "created"); 199 199 if (git_config_set_multivar_gently("log.excludeDecoration",
+1 -1
sequencer.c
··· 6089 6089 revs.topo_order = 1; 6090 6090 6091 6091 revs.pretty_given = 1; 6092 - git_config_get_string("rebase.instructionFormat", &format); 6092 + repo_config_get_string(the_repository, "rebase.instructionFormat", &format); 6093 6093 if (!format || !*format) { 6094 6094 free(format); 6095 6095 format = xstrdup("# %s");
+4 -4
transport.c
··· 54 54 return 0; 55 55 initialized = 1; 56 56 57 - if (!git_config_get_string(key, &value)) 57 + if (!repo_config_get_string(the_repository, key, &value)) 58 58 transport_use_color = git_config_colorbool(key, value); 59 59 60 60 if (!want_color_stderr(transport_use_color)) 61 61 return 0; 62 62 63 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 65 if (!value) 66 66 return config_error_nonbool(keys[i]); 67 67 if (color_parse(value, transport_colors[i]) < 0) ··· 1078 1078 char *value; 1079 1079 1080 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 1082 enum protocol_allow_config ret = 1083 1083 parse_protocol_config(key, value); 1084 1084 free(key); ··· 1088 1088 free(key); 1089 1089 1090 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 1092 enum protocol_allow_config ret = 1093 1093 parse_protocol_config("protocol.allow", value); 1094 1094 free(value);