]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: drop `git_config_get_bool()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:32 +0000 (16:08 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Jul 2025 15:15:20 +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_bool()`. All
callsites are adjusted so that they use
`repo_config_get_bool(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>
21 files changed:
archive.c
builtin/am.c
builtin/checkout.c
builtin/clone.c
builtin/credential-cache--daemon.c
builtin/gc.c
builtin/grep.c
builtin/rebase.c
compat/precompose_utf8.c
config.h
daemon.c
fetch-pack.c
http-backend.c
merge-ort.c
promisor-remote.c
read-cache.c
rerere.c
run-command.c
setup.c
t/helper/test-config.c
transport.c

index 2dd306a07a729041d39aafb9f9d0eb05d072e98b..310672b479a19f0f424780af072f8a6b39d6e424 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -760,7 +760,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
        const char **argv_copy;
        int rc;
 
-       git_config_get_bool("uploadarchive.allowunreachable", &remote_allow_unreachable);
+       repo_config_get_bool(the_repository, "uploadarchive.allowunreachable", &remote_allow_unreachable);
        repo_config(the_repository, git_default_config, NULL);
 
        describe_status.max_invocations = 1;
index a7e7cf1465aa19ad0e7b605bfc3f6be7a2e4cc0e..6073d64ae9798e44f47923bf353523770fe086a7 100644 (file)
@@ -162,18 +162,18 @@ static void am_state_init(struct am_state *state)
 
        state->prec = 4;
 
-       git_config_get_bool("am.threeway", &state->threeway);
+       repo_config_get_bool(the_repository, "am.threeway", &state->threeway);
 
        state->utf8 = 1;
 
-       git_config_get_bool("am.messageid", &state->message_id);
+       repo_config_get_bool(the_repository, "am.messageid", &state->message_id);
 
        state->scissors = SCISSORS_UNSET;
        state->quoted_cr = quoted_cr_unset;
 
        strvec_init(&state->git_apply_opts);
 
-       if (!git_config_get_bool("commit.gpgsign", &gpgsign))
+       if (!repo_config_get_bool(the_repository, "commit.gpgsign", &gpgsign))
                state->sign_commit = gpgsign ? "" : NULL;
 }
 
@@ -965,7 +965,7 @@ static int split_mail(struct am_state *state, enum patch_format patch_format,
 {
        if (keep_cr < 0) {
                keep_cr = 0;
-               git_config_get_bool("am.keepcr", &keep_cr);
+               repo_config_get_bool(the_repository, "am.keepcr", &keep_cr);
        }
 
        switch (patch_format) {
index 948ff7bdda7c17eeea648f6671d8fa2ff39a37a1..37efde59898093ffdeca3f09b23c6dd2373107bb 100644 (file)
@@ -291,7 +291,7 @@ static int checkout_merged(int pos, const struct checkout *state,
        read_mmblob(&ours, &threeway[1]);
        read_mmblob(&theirs, &threeway[2]);
 
-       git_config_get_bool("merge.renormalize", &renormalize);
+       repo_config_get_bool(the_repository, "merge.renormalize", &renormalize);
        ll_opts.renormalize = renormalize;
        ll_opts.conflict_style = conflict_style;
        merge_status = ll_merge(&result_buf, path, &ancestor, "base",
index 3c6d8529b6c3a3742c0bad14c8008b91cc3570ac..34eea11db4d9caff714f1043e39012b5974289fa 100644 (file)
@@ -1150,7 +1150,7 @@ int cmd_clone(int argc,
                        strbuf_reset(&sb);
                }
 
-               if (!git_config_get_bool("submodule.stickyRecursiveClone", &val) &&
+               if (!repo_config_get_bool(the_repository, "submodule.stickyRecursiveClone", &val) &&
                    val)
                        string_list_append(&option_config, "submodule.recurse=true");
 
index 5065ff4660bec90f12981f1ae54952c41197d1ca..65cc619bec2869954b88c9753de6dcbe48681165 100644 (file)
@@ -307,7 +307,7 @@ int cmd_credential_cache_daemon(int argc,
                OPT_END()
        };
 
-       git_config_get_bool("credentialcache.ignoresighup", &ignore_sighup);
+       repo_config_get_bool(the_repository, "credentialcache.ignoresighup", &ignore_sighup);
 
        argc = parse_options(argc, argv, prefix, options, usage, 0);
        socket_path = argv[0];
index d15daf596255970f36e0463f69f5f39a830ec658..fa62e4f262720c2013f48cf78972318c8550bec1 100644 (file)
@@ -193,8 +193,8 @@ static void gc_config(struct gc_config *cfg)
        repo_config_get_int(the_repository, "gc.aggressivedepth", &cfg->aggressive_depth);
        repo_config_get_int(the_repository, "gc.auto", &cfg->gc_auto_threshold);
        repo_config_get_int(the_repository, "gc.autopacklimit", &cfg->gc_auto_pack_limit);
-       git_config_get_bool("gc.autodetach", &cfg->detach_auto);
-       git_config_get_bool("gc.cruftpacks", &cfg->cruft_packs);
+       repo_config_get_bool(the_repository, "gc.autodetach", &cfg->detach_auto);
+       repo_config_get_bool(the_repository, "gc.cruftpacks", &cfg->cruft_packs);
        repo_config_get_ulong(the_repository, "gc.maxcruftsize", &cfg->max_cruft_size);
 
        if (!repo_config_get_expiry(the_repository, "gc.pruneexpire", &owned)) {
@@ -1779,7 +1779,7 @@ static void initialize_task_config(struct maintenance_run_opts *opts,
                strbuf_reset(&config_name);
                strbuf_addf(&config_name, "maintenance.%s.enabled",
                            tasks[i].name);
-               if (!git_config_get_bool(config_name.buf, &config_value))
+               if (!repo_config_get_bool(the_repository, config_name.buf, &config_value))
                        strategy.tasks[i].enabled = config_value;
                if (!strategy.tasks[i].enabled)
                        continue;
index 7982dda9a3b6829a72790cdd3da9ab7dacca6c1e..8fcb69dbf2cba5670df58f58dffb279d6b9078d5 100644 (file)
@@ -1058,7 +1058,7 @@ int cmd_grep(int argc,
 
        if (use_index && !startup_info->have_repository) {
                int fallback = 0;
-               git_config_get_bool("grep.fallbacktonoindex", &fallback);
+               repo_config_get_bool(the_repository, "grep.fallbacktonoindex", &fallback);
                if (fallback)
                        use_index = 0;
                else
index 0c3daa4b8140d88dc1a42b24cb1e227c945f71b3..72a52bdfb9872e9b221ba2df1aa8cb6fa74541c8 100644 (file)
@@ -340,7 +340,7 @@ static int run_sequencer_rebase(struct rebase_options *opts)
        unsigned flags = 0;
        int abbreviate_commands = 0, ret = 0;
 
-       git_config_get_bool("rebase.abbreviatecommands", &abbreviate_commands);
+       repo_config_get_bool(the_repository, "rebase.abbreviatecommands", &abbreviate_commands);
 
        flags |= opts->keep_empty ? TODO_LIST_KEEP_EMPTY : 0;
        flags |= abbreviate_commands ? TODO_LIST_ABBREVIATE_CMDS : 0;
index 12e38e0ea3c57075ac6752876344a32125c3e4e6..3985ed108eb458318201a41ae03b261fb4a47084 100644 (file)
@@ -75,7 +75,7 @@ const char *precompose_string_if_needed(const char *in)
                iconv_t ic_prec;
                char *out;
                if (precomposed_unicode < 0)
-                       git_config_get_bool("core.precomposeunicode", &precomposed_unicode);
+                       repo_config_get_bool(the_repository, "core.precomposeunicode", &precomposed_unicode);
                if (precomposed_unicode != 1)
                        return in;
                ic_prec = iconv_open(repo_encoding, path_encoding);
index e22c07a4488bfa29a43119af28f599172454fdd3..c9f582c7c55d7cdfcb4ee73d431bda24495fd5fc 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_bool(const char *key, int *dest)
-{
-       return repo_config_get_bool(the_repository, key, dest);
-}
-
 static inline int git_config_get_bool_or_int(const char *key, int *is_bool, int *dest)
 {
        return repo_config_get_bool_or_int(the_repository, key, is_bool, dest);
index 61cd50f7200f99b06d82c2b8347e1eae6cd5348d..cb2092355573553d2ea18e7d10ea5e11f9c94566 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -402,7 +402,7 @@ static int run_service(const char *dir, struct daemon_service *service,
 
        if (service->overridable) {
                strbuf_addf(&var, "daemon.%s", service->config_name);
-               git_config_get_bool(var.buf, &enabled);
+               repo_config_get_bool(the_repository, var.buf, &enabled);
                strbuf_release(&var);
        }
        if (!enabled) {
index 1f184efb3c9c60909f042290c9153380609c1d07..94b1436c5c267a925767d6f23c708bd030a69b55 100644 (file)
@@ -1903,10 +1903,10 @@ static void fetch_pack_config(void)
 {
        repo_config_get_int(the_repository, "fetch.unpacklimit", &fetch_unpack_limit);
        repo_config_get_int(the_repository, "transfer.unpacklimit", &transfer_unpack_limit);
-       git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta);
-       git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects);
-       git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
-       git_config_get_bool("transfer.advertisesid", &advertise_sid);
+       repo_config_get_bool(the_repository, "repack.usedeltabaseoffset", &prefer_ofs_delta);
+       repo_config_get_bool(the_repository, "fetch.fsckobjects", &fetch_fsck_objects);
+       repo_config_get_bool(the_repository, "transfer.fsckobjects", &transfer_fsck_objects);
+       repo_config_get_bool(the_repository, "transfer.advertisesid", &advertise_sid);
        if (!uri_protocols.nr) {
                char *str;
 
index 3d5d5a84646ebc863abe4e5413531026fdfb3ff8..d5dfe762bb51783cf6f81de8cfa79075d26075c3 100644 (file)
@@ -246,13 +246,13 @@ static void http_config(void)
        int i, value = 0;
        struct strbuf var = STRBUF_INIT;
 
-       git_config_get_bool("http.getanyfile", &getanyfile);
+       repo_config_get_bool(the_repository, "http.getanyfile", &getanyfile);
        repo_config_get_ulong(the_repository, "http.maxrequestbuffer", &max_request_buffer);
 
        for (i = 0; i < ARRAY_SIZE(rpc_service); i++) {
                struct rpc_service *svc = &rpc_service[i];
                strbuf_addf(&var, "http.%s", svc->config_name);
-               if (!git_config_get_bool(var.buf, &value))
+               if (!repo_config_get_bool(the_repository, var.buf, &value))
                        svc->enabled = value;
                strbuf_reset(&var);
        }
index 45fd41f8dfdd2d5bb5aee8261103959e72b80f70..86896ff11b014d9c43413d7589aa0067e587dfd5 100644 (file)
@@ -5356,7 +5356,7 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
        repo_config_get_int(the_repository, "merge.verbosity", &opt->verbosity);
        repo_config_get_int(the_repository, "diff.renamelimit", &opt->rename_limit);
        repo_config_get_int(the_repository, "merge.renamelimit", &opt->rename_limit);
-       git_config_get_bool("merge.renormalize", &renormalize);
+       repo_config_get_bool(the_repository, "merge.renormalize", &renormalize);
        opt->renormalize = renormalize;
        if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
                opt->detect_renames = git_config_rename("diff.renames", value);
index a9c877d9cfa30f77357b53c9f8bdca2e9f8efda8..08b0da896227c81fcfd919462dc6d38581bfb4ba 100644 (file)
@@ -46,7 +46,7 @@ static int fetch_objects(struct repository *repo,
                     "fetch", remote_name, "--no-tags",
                     "--no-write-fetch-head", "--recurse-submodules=no",
                     "--filter=blob:none", "--stdin", NULL);
-       if (!git_config_get_bool("promisor.quiet", &quiet) && quiet)
+       if (!repo_config_get_bool(the_repository, "promisor.quiet", &quiet) && quiet)
                strvec_push(&child.args, "--quiet");
        if (start_command(&child))
                die(_("promisor-remote: unable to fork off fetch subprocess"));
@@ -343,7 +343,7 @@ char *promisor_remote_info(struct repository *repo)
        struct strvec names = STRVEC_INIT;
        struct strvec urls = STRVEC_INIT;
 
-       git_config_get_bool("promisor.advertise", &advertise_promisors);
+       repo_config_get_bool(the_repository, "promisor.advertise", &advertise_promisors);
 
        if (!advertise_promisors)
                return NULL;
index 5cf41b81f1fd8bb8759db2958769b83e2fe00a58..4fdde758d1bf6a94a6b211bccaa6672b22d09072 100644 (file)
@@ -2755,7 +2755,7 @@ static int record_eoie(void)
 {
        int val;
 
-       if (!git_config_get_bool("index.recordendofindexentries", &val))
+       if (!repo_config_get_bool(the_repository, "index.recordendofindexentries", &val))
                return val;
 
        /*
@@ -2770,7 +2770,7 @@ static int record_ieot(void)
 {
        int val;
 
-       if (!git_config_get_bool("index.recordoffsettable", &val))
+       if (!repo_config_get_bool(the_repository, "index.recordoffsettable", &val))
                return val;
 
        /*
index 1ac2075144c97c6fcb2cab8837a98f5f97667e9b..c7c3e535ce50459bfbec985ace524eec83d0c594 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -877,8 +877,8 @@ static int do_plain_rerere(struct repository *r,
 
 static void git_rerere_config(void)
 {
-       git_config_get_bool("rerere.enabled", &rerere_enabled);
-       git_config_get_bool("rerere.autoupdate", &rerere_autoupdate);
+       repo_config_get_bool(the_repository, "rerere.enabled", &rerere_enabled);
+       repo_config_get_bool(the_repository, "rerere.autoupdate", &rerere_autoupdate);
        repo_config(the_repository, git_default_config, NULL);
 }
 
index 8833b2336785d92175f37d356ab7aa9904e69d8d..ed9575bd6a8cbbab0f25b92e09cf9c2752498523 100644 (file)
@@ -1817,7 +1817,7 @@ int prepare_auto_maintenance(int quiet, struct child_process *maint)
 {
        int enabled, auto_detach;
 
-       if (!git_config_get_bool("maintenance.auto", &enabled) &&
+       if (!repo_config_get_bool(the_repository, "maintenance.auto", &enabled) &&
            !enabled)
                return 0;
 
@@ -1826,8 +1826,8 @@ int prepare_auto_maintenance(int quiet, struct child_process *maint)
         * honoring `gc.autoDetach`. This is somewhat weird, but required to
         * retain behaviour from when we used to run git-gc(1) here.
         */
-       if (git_config_get_bool("maintenance.autodetach", &auto_detach) &&
-           git_config_get_bool("gc.autodetach", &auto_detach))
+       if (repo_config_get_bool(the_repository, "maintenance.autodetach", &auto_detach) &&
+           repo_config_get_bool(the_repository, "gc.autodetach", &auto_detach))
                auto_detach = 1;
 
        maint->git_cmd = 1;
diff --git a/setup.c b/setup.c
index 9661c5d5d5d7aa99157f509aba5d80971e0bd9ce..a06bb921b3a99c8c5823f37fe3f728709710c3ee 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1877,7 +1877,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
         * the core.precomposeunicode configuration, this
         * has to happen after the above block that finds
         * out where the repository is, i.e. a preparation
-        * for calling git_config_get_bool().
+        * for calling repo_config_get_bool().
         */
        if (prefix) {
                prefix = precompose_string_if_needed(prefix);
index ce1e333051676e3f414ca0cf9ab59e834af43a25..9f8cca7c48cfe3162fc9b4b403ac91f895bc08fd 100644 (file)
@@ -163,7 +163,7 @@ int cmd__config(int argc, const char **argv)
                        goto exit1;
                }
        } else if (argc == 3 && !strcmp(argv[1], "get_bool")) {
-               if (!git_config_get_bool(argv[2], &val)) {
+               if (!repo_config_get_bool(the_repository, argv[2], &val)) {
                        printf("%d\n", val);
                        goto exit0;
                } else {
index 89e6297ce222bbf0df61f702887b00d0b215b2b4..e305d6bd228b456daace3e40aa8521aba2077534 100644 (file)
@@ -1602,7 +1602,7 @@ int transport_get_remote_bundle_uri(struct transport *transport)
         * Don't request bundle-uri from the server unless configured to
         * do so by the transfer.bundleURI=true config option.
         */
-       if (git_config_get_bool("transfer.bundleuri", &value) || !value)
+       if (repo_config_get_bool(the_repository, "transfer.bundleuri", &value) || !value)
                return 0;
 
        if (!transport->bundles->baseURI)