Skip to content

Commit 627d08c

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_get_string() wrapper
In 036876a (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4f5ba82 commit 627d08c

File tree

12 files changed

+25
-30
lines changed

12 files changed

+25
-30
lines changed

apply.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ struct gitdiff_data {
4848

4949
static void git_apply_config(void)
5050
{
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);
5353
repo_config(the_repository, git_xmerge_config, NULL);
5454
}
5555

branch.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
355355
char *v = NULL;
356356
struct strbuf name = STRBUF_INIT;
357357
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)) {
359359
strbuf_release(&name);
360360
return -1;
361361
}

builtin/gc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,12 @@ static void gc_config(struct gc_config *cfg)
218218
if (!git_config_get_ulong("core.deltabasecachelimit", &ulongval))
219219
cfg->delta_base_cache_limit = ulongval;
220220

221-
if (!git_config_get_string("gc.repackfilter", &owned)) {
221+
if (!repo_config_get_string(the_repository, "gc.repackfilter", &owned)) {
222222
free(cfg->repack_filter);
223223
cfg->repack_filter = owned;
224224
}
225225

226-
if (!git_config_get_string("gc.repackfilterto", &owned)) {
226+
if (!repo_config_get_string(the_repository, "gc.repackfilterto", &owned)) {
227227
free(cfg->repack_filter_to);
228228
cfg->repack_filter_to = owned;
229229
}

builtin/log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static void set_default_decoration_filter(struct decoration_filter *decoration_f
235235
* since the command-line takes precedent.
236236
*/
237237
if (use_default_decoration_filter &&
238-
!git_config_get_string("log.initialdecorationset", &value) &&
238+
!repo_config_get_string(the_repository, "log.initialdecorationset", &value) &&
239239
!strcmp("all", value))
240240
use_default_decoration_filter = 0;
241241
free(value);

builtin/notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ static int git_config_get_notes_strategy(const char *key,
873873
{
874874
char *value;
875875

876-
if (git_config_get_string(key, &value))
876+
if (repo_config_get_string(the_repository, key, &value))
877877
return 1;
878878
if (parse_notes_merge_strategy(value, strategy))
879879
git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);

builtin/submodule--helper.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static char *resolve_relative_url(const char *rel_url, const char *up_path, int
5353
struct strbuf remotesb = STRBUF_INIT;
5454

5555
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)) {
5757
if (!quiet)
5858
warning(_("could not look up configuration '%s'. "
5959
"Assuming this repository is its own "
@@ -468,7 +468,7 @@ static void init_submodule(const char *path, const char *prefix,
468468
* .gitmodules, so look it up directly.
469469
*/
470470
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)) {
472472
if (!sub->url)
473473
die(_("No url found for submodule path '%s' in .gitmodules"),
474474
displaypath);
@@ -1623,11 +1623,11 @@ static void prepare_possible_alternates(const char *sm_name,
16231623
char *sm_alternate = NULL, *error_strategy = NULL;
16241624
struct submodule_alternate_setup sas = SUBMODULE_ALTERNATE_SETUP_INIT;
16251625

1626-
git_config_get_string("submodule.alternateLocation", &sm_alternate);
1626+
repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
16271627
if (!sm_alternate)
16281628
return;
16291629

1630-
git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
1630+
repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
16311631

16321632
if (!error_strategy)
16331633
error_strategy = xstrdup("die");
@@ -1808,11 +1808,11 @@ static int clone_submodule(const struct module_clone_data *clone_data,
18081808
die(_("could not get submodule directory for '%s'"), clone_data_path);
18091809

18101810
/* 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);
18121812
if (sm_alternate)
18131813
git_config_set_in_file(p, "submodule.alternateLocation",
18141814
sm_alternate);
1815-
git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
1815+
repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
18161816
if (error_strategy)
18171817
git_config_set_in_file(p, "submodule.alternateErrorStrategy",
18181818
error_strategy);

config.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -719,11 +719,6 @@ NORETURN void git_die_config_linenr(const char *key, const char *filename, int l
719719
int lookup_config(const char **mapping, int nr_mapping, const char *var);
720720

721721
# 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-
727722
static inline int git_config_get_string_tmp(const char *key, const char **dest)
728723
{
729724
return repo_config_get_string_tmp(the_repository, key, dest);

fetch-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ static void fetch_pack_config(void)
19101910
if (!uri_protocols.nr) {
19111911
char *str;
19121912

1913-
if (!git_config_get_string("fetch.uriprotocols", &str) && str) {
1913+
if (!repo_config_get_string(the_repository, "fetch.uriprotocols", &str) && str) {
19141914
string_list_split(&uri_protocols, str, ',', -1);
19151915
free(str);
19161916
}

merge-ort.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5358,15 +5358,15 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
53585358
git_config_get_int("merge.renamelimit", &opt->rename_limit);
53595359
git_config_get_bool("merge.renormalize", &renormalize);
53605360
opt->renormalize = renormalize;
5361-
if (!git_config_get_string("diff.renames", &value)) {
5361+
if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
53625362
opt->detect_renames = git_config_rename("diff.renames", value);
53635363
free(value);
53645364
}
5365-
if (!git_config_get_string("merge.renames", &value)) {
5365+
if (!repo_config_get_string(the_repository, "merge.renames", &value)) {
53665366
opt->detect_renames = git_config_rename("merge.renames", value);
53675367
free(value);
53685368
}
5369-
if (!git_config_get_string("merge.directoryrenames", &value)) {
5369+
if (!repo_config_get_string(the_repository, "merge.directoryrenames", &value)) {
53705370
int boolval = git_parse_maybe_bool(value);
53715371
if (0 <= boolval) {
53725372
opt->detect_directory_renames = boolval ?
@@ -5379,7 +5379,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
53795379
free(value);
53805380
}
53815381
if (ui) {
5382-
if (!git_config_get_string("diff.algorithm", &value)) {
5382+
if (!repo_config_get_string(the_repository, "diff.algorithm", &value)) {
53835383
long diff_algorithm = parse_algorithm_value(value);
53845384
if (diff_algorithm < 0)
53855385
die(_("unknown value for config '%s': %s"), "diff.algorithm", value);

scalar.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
101101
int res;
102102

103103
if ((reconfigure && config->overwrite_on_reconfigure) ||
104-
git_config_get_string(config->key, &value)) {
104+
repo_config_get_string(the_repository, config->key, &value)) {
105105
trace2_data_string("scalar", the_repository, config->key, "created");
106106
res = git_config_set_gently(config->key, config->value);
107107
} else {
@@ -193,7 +193,7 @@ static int set_recommended_config(int reconfigure)
193193
* The `log.excludeDecoration` setting is special because it allows
194194
* for multiple values.
195195
*/
196-
if (git_config_get_string("log.excludeDecoration", &value)) {
196+
if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) {
197197
trace2_data_string("scalar", the_repository,
198198
"log.excludeDecoration", "created");
199199
if (git_config_set_multivar_gently("log.excludeDecoration",

0 commit comments

Comments
 (0)