]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: drop `git_config_get_string()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:28 +0000 (16:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2025 15:15:19 +0000 (08:15 -0700)
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>
12 files changed:
apply.c
branch.c
builtin/gc.c
builtin/log.c
builtin/notes.c
builtin/submodule--helper.c
config.h
fetch-pack.c
merge-ort.c
scalar.c
sequencer.c
transport.c

diff --git a/apply.c b/apply.c
index d2381a157c0a8342ae5e6997b25930f80b3f5b4d..45eb790d1334cc1ccfd98159b7828f704af0e2a1 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -48,8 +48,8 @@ struct gitdiff_data {
 
 static void git_apply_config(void)
 {
-       git_config_get_string("apply.whitespace", &apply_default_whitespace);
-       git_config_get_string("apply.ignorewhitespace", &apply_default_ignorewhitespace);
+       repo_config_get_string(the_repository, "apply.whitespace", &apply_default_whitespace);
+       repo_config_get_string(the_repository, "apply.ignorewhitespace", &apply_default_ignorewhitespace);
        repo_config(the_repository, git_xmerge_config, NULL);
 }
 
index 93f5b4e8dd9fe53ae4412827c458bade7c341278..b4811671fc741c6abe6dca58d42015d1b60abca2 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -355,7 +355,7 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
        char *v = NULL;
        struct strbuf name = STRBUF_INIT;
        strbuf_addf(&name, "branch.%s.description", branch_name);
-       if (git_config_get_string(name.buf, &v)) {
+       if (repo_config_get_string(the_repository, name.buf, &v)) {
                strbuf_release(&name);
                return -1;
        }
index f395cc57a157621244c75a076e108163ff421ddb..d8f7a1858cb22e9a858c647d56d2f274cd2c770f 100644 (file)
@@ -218,12 +218,12 @@ static void gc_config(struct gc_config *cfg)
        if (!git_config_get_ulong("core.deltabasecachelimit", &ulongval))
                cfg->delta_base_cache_limit = ulongval;
 
-       if (!git_config_get_string("gc.repackfilter", &owned)) {
+       if (!repo_config_get_string(the_repository, "gc.repackfilter", &owned)) {
                free(cfg->repack_filter);
                cfg->repack_filter = owned;
        }
 
-       if (!git_config_get_string("gc.repackfilterto", &owned)) {
+       if (!repo_config_get_string(the_repository, "gc.repackfilterto", &owned)) {
                free(cfg->repack_filter_to);
                cfg->repack_filter_to = owned;
        }
index b512f12e8058a371ac227fedc7a3dba2adb9871f..a9969ad00a03622fb7872dd5f4ce62d44a0ec6a5 100644 (file)
@@ -235,7 +235,7 @@ static void set_default_decoration_filter(struct decoration_filter *decoration_f
         * since the command-line takes precedent.
         */
        if (use_default_decoration_filter &&
-           !git_config_get_string("log.initialdecorationset", &value) &&
+           !repo_config_get_string(the_repository, "log.initialdecorationset", &value) &&
            !strcmp("all", value))
                use_default_decoration_filter = 0;
        free(value);
index 17004cdb10eb75c3675b67c2edc517fb87277438..d2252cf5346b81d083f8c75b08e728f43ff0f2dc 100644 (file)
@@ -873,7 +873,7 @@ static int git_config_get_notes_strategy(const char *key,
 {
        char *value;
 
-       if (git_config_get_string(key, &value))
+       if (repo_config_get_string(the_repository, key, &value))
                return 1;
        if (parse_notes_merge_strategy(value, strategy))
                git_die_config(the_repository, key, _("unknown notes merge strategy %s"), value);
index 6bcc741a6ac894bd69b7be8b72bd467f5532db4d..18aa69f0cae6fdc922294503b8a02e4a7e90de06 100644 (file)
@@ -53,7 +53,7 @@ static char *resolve_relative_url(const char *rel_url, const char *up_path, int
        struct strbuf remotesb = STRBUF_INIT;
 
        strbuf_addf(&remotesb, "remote.%s.url", remote);
-       if (git_config_get_string(remotesb.buf, &remoteurl)) {
+       if (repo_config_get_string(the_repository, remotesb.buf, &remoteurl)) {
                if (!quiet)
                        warning(_("could not look up configuration '%s'. "
                                  "Assuming this repository is its own "
@@ -468,7 +468,7 @@ static void init_submodule(const char *path, const char *prefix,
         * .gitmodules, so look it up directly.
         */
        strbuf_addf(&sb, "submodule.%s.url", sub->name);
-       if (git_config_get_string(sb.buf, &url)) {
+       if (repo_config_get_string(the_repository, sb.buf, &url)) {
                if (!sub->url)
                        die(_("No url found for submodule path '%s' in .gitmodules"),
                                displaypath);
@@ -1623,11 +1623,11 @@ static void prepare_possible_alternates(const char *sm_name,
        char *sm_alternate = NULL, *error_strategy = NULL;
        struct submodule_alternate_setup sas = SUBMODULE_ALTERNATE_SETUP_INIT;
 
-       git_config_get_string("submodule.alternateLocation", &sm_alternate);
+       repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
        if (!sm_alternate)
                return;
 
-       git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
+       repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
 
        if (!error_strategy)
                error_strategy = xstrdup("die");
@@ -1808,11 +1808,11 @@ static int clone_submodule(const struct module_clone_data *clone_data,
                die(_("could not get submodule directory for '%s'"), clone_data_path);
 
        /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
-       git_config_get_string("submodule.alternateLocation", &sm_alternate);
+       repo_config_get_string(the_repository, "submodule.alternateLocation", &sm_alternate);
        if (sm_alternate)
                git_config_set_in_file(p, "submodule.alternateLocation",
                                       sm_alternate);
-       git_config_get_string("submodule.alternateErrorStrategy", &error_strategy);
+       repo_config_get_string(the_repository, "submodule.alternateErrorStrategy", &error_strategy);
        if (error_strategy)
                git_config_set_in_file(p, "submodule.alternateErrorStrategy",
                                       error_strategy);
index f6635e48c2342be453905a88b9d1cd80ff9d1825..8887ebf62eadae8f2b11d4a21ae16f7a1fad35fa 100644 (file)
--- a/config.h
+++ b/config.h
@@ -719,11 +719,6 @@ NORETURN void git_die_config_linenr(const char *key, const char *filename, int l
 int lookup_config(const char **mapping, int nr_mapping, const char *var);
 
 # ifdef USE_THE_REPOSITORY_VARIABLE
-static inline int git_config_get_string(const char *key, char **dest)
-{
-       return repo_config_get_string(the_repository, key, dest);
-}
-
 static inline int git_config_get_string_tmp(const char *key, const char **dest)
 {
        return repo_config_get_string_tmp(the_repository, key, dest);
index 11344206f73ce8cf1232a1e4861885319cee8874..04768087879ad0896320f82bf5bb6c88e93b3626 100644 (file)
@@ -1910,7 +1910,7 @@ static void fetch_pack_config(void)
        if (!uri_protocols.nr) {
                char *str;
 
-               if (!git_config_get_string("fetch.uriprotocols", &str) && str) {
+               if (!repo_config_get_string(the_repository, "fetch.uriprotocols", &str) && str) {
                        string_list_split(&uri_protocols, str, ',', -1);
                        free(str);
                }
index 49aa37a8f236bd23d83bb81a894ab9e4436e1756..29789579c9b12279a80e802bc9b5ed5440ddbfc3 100644 (file)
@@ -5358,15 +5358,15 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
        git_config_get_int("merge.renamelimit", &opt->rename_limit);
        git_config_get_bool("merge.renormalize", &renormalize);
        opt->renormalize = renormalize;
-       if (!git_config_get_string("diff.renames", &value)) {
+       if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
                opt->detect_renames = git_config_rename("diff.renames", value);
                free(value);
        }
-       if (!git_config_get_string("merge.renames", &value)) {
+       if (!repo_config_get_string(the_repository, "merge.renames", &value)) {
                opt->detect_renames = git_config_rename("merge.renames", value);
                free(value);
        }
-       if (!git_config_get_string("merge.directoryrenames", &value)) {
+       if (!repo_config_get_string(the_repository, "merge.directoryrenames", &value)) {
                int boolval = git_parse_maybe_bool(value);
                if (0 <= boolval) {
                        opt->detect_directory_renames = boolval ?
@@ -5379,7 +5379,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
                free(value);
        }
        if (ui) {
-               if (!git_config_get_string("diff.algorithm", &value)) {
+               if (!repo_config_get_string(the_repository, "diff.algorithm", &value)) {
                        long diff_algorithm = parse_algorithm_value(value);
                        if (diff_algorithm < 0)
                                die(_("unknown value for config '%s': %s"), "diff.algorithm", value);
index 2aaff5aa10958512a65d25942684369a422468f5..07f855c9913985c2198b4a82fbe93b9ba1df0148 100644 (file)
--- a/scalar.c
+++ b/scalar.c
@@ -101,7 +101,7 @@ static int set_scalar_config(const struct scalar_config *config, int reconfigure
        int res;
 
        if ((reconfigure && config->overwrite_on_reconfigure) ||
-           git_config_get_string(config->key, &value)) {
+           repo_config_get_string(the_repository, config->key, &value)) {
                trace2_data_string("scalar", the_repository, config->key, "created");
                res = git_config_set_gently(config->key, config->value);
        } else {
@@ -193,7 +193,7 @@ static int set_recommended_config(int reconfigure)
         * The `log.excludeDecoration` setting is special because it allows
         * for multiple values.
         */
-       if (git_config_get_string("log.excludeDecoration", &value)) {
+       if (repo_config_get_string(the_repository, "log.excludeDecoration", &value)) {
                trace2_data_string("scalar", the_repository,
                                   "log.excludeDecoration", "created");
                if (git_config_set_multivar_gently("log.excludeDecoration",
index df207f33e07bb72aca60b08c6e6b20b0b526a0f5..f3bada39b4075b2e5e67e0c318e42a2b9398da14 100644 (file)
@@ -6089,7 +6089,7 @@ int sequencer_make_script(struct repository *r, struct strbuf *out, int argc,
        revs.topo_order = 1;
 
        revs.pretty_given = 1;
-       git_config_get_string("rebase.instructionFormat", &format);
+       repo_config_get_string(the_repository, "rebase.instructionFormat", &format);
        if (!format || !*format) {
                free(format);
                format = xstrdup("# %s");
index a246afd09fa5d5f48c32450bc10495fde7025b01..89e6297ce222bbf0df61f702887b00d0b215b2b4 100644 (file)
@@ -54,14 +54,14 @@ static int transport_color_config(void)
                return 0;
        initialized = 1;
 
-       if (!git_config_get_string(key, &value))
+       if (!repo_config_get_string(the_repository, key, &value))
                transport_use_color = git_config_colorbool(key, value);
 
        if (!want_color_stderr(transport_use_color))
                return 0;
 
        for (size_t i = 0; i < ARRAY_SIZE(keys); i++)
-               if (!git_config_get_string(keys[i], &value)) {
+               if (!repo_config_get_string(the_repository, keys[i], &value)) {
                        if (!value)
                                return config_error_nonbool(keys[i]);
                        if (color_parse(value, transport_colors[i]) < 0)
@@ -1078,7 +1078,7 @@ static enum protocol_allow_config get_protocol_config(const char *type)
        char *value;
 
        /* first check the per-protocol config */
-       if (!git_config_get_string(key, &value)) {
+       if (!repo_config_get_string(the_repository, key, &value)) {
                enum protocol_allow_config ret =
                        parse_protocol_config(key, value);
                free(key);
@@ -1088,7 +1088,7 @@ static enum protocol_allow_config get_protocol_config(const char *type)
        free(key);
 
        /* if defined, fallback to user-defined default for unknown protocols */
-       if (!git_config_get_string("protocol.allow", &value)) {
+       if (!repo_config_get_string(the_repository, "protocol.allow", &value)) {
                enum protocol_allow_config ret =
                        parse_protocol_config("protocol.allow", value);
                free(value);