]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: drop `git_config_get_int()` wrapper
authorPatrick Steinhardt <ps@pks.im>
Wed, 23 Jul 2025 14:08:30 +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_int()`. All
callsites are adjusted so that they use
`repo_config_get_int(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>
13 files changed:
builtin/credential-store.c
builtin/fast-import.c
builtin/fetch.c
builtin/gc.c
config.h
fetch-pack.c
fsmonitor.c
merge-ort.c
parallel-checkout.c
refs.c
refs/packed-backend.c
sequencer.c
t/helper/test-config.c

index e669e99dbfb9a718ff83aa59f24c307fa35f981e..b74e06cc93d9cda13550a3bf2a161ea9775756af 100644 (file)
@@ -66,7 +66,7 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
 {
        int timeout_ms = 1000;
 
-       git_config_get_int("credentialstore.locktimeoutms", &timeout_ms);
+       repo_config_get_int(the_repository, "credentialstore.locktimeoutms", &timeout_ms);
        if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0)
                die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
        if (extra)
index 607441e921b38aa43ed5f42eeac37fa89d63f473..9b0ae4371486787e20ced1b8ef67c3fc4c8cb0a7 100644 (file)
@@ -3527,7 +3527,7 @@ static void git_pack_config(void)
                if (max_depth > MAX_DEPTH)
                        max_depth = MAX_DEPTH;
        }
-       if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
+       if (!repo_config_get_int(the_repository, "pack.indexversion", &indexversion_value)) {
                pack_idx_opts.version = indexversion_value;
                if (pack_idx_opts.version > 2)
                        git_die_config(the_repository, "pack.indexversion",
@@ -3536,9 +3536,9 @@ static void git_pack_config(void)
        if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
                max_packsize = packsizelimit_value;
 
-       if (!git_config_get_int("fastimport.unpacklimit", &limit))
+       if (!repo_config_get_int(the_repository, "fastimport.unpacklimit", &limit))
                unpack_limit = limit;
-       else if (!git_config_get_int("transfer.unpacklimit", &limit))
+       else if (!repo_config_get_int(the_repository, "transfer.unpacklimit", &limit))
                unpack_limit = limit;
 
        repo_config(the_repository, git_default_config, NULL);
index 52eae4b972ddceefc36a7ea678d6a77558c1098b..24645c465335de70cece7e1a2109eeaec4ed1748 100644 (file)
@@ -2683,12 +2683,12 @@ int cmd_fetch(int argc,
                         * but respect config settings disabling it.
                         */
                        int opt_val;
-                       if (git_config_get_int("gc.autopacklimit", &opt_val))
+                       if (repo_config_get_int(the_repository, "gc.autopacklimit", &opt_val))
                                opt_val = -1;
                        if (opt_val != 0)
                                git_config_push_parameter("gc.autoPackLimit=1");
 
-                       if (git_config_get_int("maintenance.incremental-repack.auto", &opt_val))
+                       if (repo_config_get_int(the_repository, "maintenance.incremental-repack.auto", &opt_val))
                                opt_val = -1;
                        if (opt_val != 0)
                                git_config_push_parameter("maintenance.incremental-repack.auto=-1");
index a2b8fbc9f3d87c4ce5bc10ba80a9d07c12a89186..cf175b8f1b76106312937a0191f6e0466fd33e15 100644 (file)
@@ -189,10 +189,10 @@ static void gc_config(struct gc_config *cfg)
            gc_config_is_timestamp_never("gc.reflogexpireunreachable"))
                cfg->prune_reflogs = 0;
 
-       git_config_get_int("gc.aggressivewindow", &cfg->aggressive_window);
-       git_config_get_int("gc.aggressivedepth", &cfg->aggressive_depth);
-       git_config_get_int("gc.auto", &cfg->gc_auto_threshold);
-       git_config_get_int("gc.autopacklimit", &cfg->gc_auto_pack_limit);
+       repo_config_get_int(the_repository, "gc.aggressivewindow", &cfg->aggressive_window);
+       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);
        git_config_get_ulong("gc.maxcruftsize", &cfg->max_cruft_size);
@@ -332,7 +332,7 @@ static int reflog_expire_condition(struct gc_config *cfg UNUSED)
        };
        int limit = 100;
 
-       git_config_get_int("maintenance.reflog-expire.auto", &limit);
+       repo_config_get_int(the_repository, "maintenance.reflog-expire.auto", &limit);
        if (!limit)
                return 0;
        if (limit < 0)
@@ -378,7 +378,7 @@ static int worktree_prune_condition(struct gc_config *cfg)
        struct dirent *d;
        DIR *dir = NULL;
 
-       git_config_get_int("maintenance.worktree-prune.auto", &limit);
+       repo_config_get_int(the_repository, "maintenance.worktree-prune.auto", &limit);
        if (limit <= 0) {
                should_prune = limit < 0;
                goto out;
@@ -423,7 +423,7 @@ static int rerere_gc_condition(struct gc_config *cfg UNUSED)
        int should_gc = 0, limit = 1;
        DIR *dir = NULL;
 
-       git_config_get_int("maintenance.rerere-gc.auto", &limit);
+       repo_config_get_int(the_repository, "maintenance.rerere-gc.auto", &limit);
        if (limit <= 0) {
                should_gc = limit < 0;
                goto out;
@@ -1161,8 +1161,8 @@ static int should_write_commit_graph(struct gc_config *cfg UNUSED)
 
        data.num_not_in_graph = 0;
        data.limit = 100;
-       git_config_get_int("maintenance.commit-graph.auto",
-                          &data.limit);
+       repo_config_get_int(the_repository, "maintenance.commit-graph.auto",
+                           &data.limit);
 
        if (!data.limit)
                return 0;
@@ -1300,8 +1300,8 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)
 {
        int count = 0;
 
-       git_config_get_int("maintenance.loose-objects.auto",
-                          &loose_object_auto_limit);
+       repo_config_get_int(the_repository, "maintenance.loose-objects.auto",
+                           &loose_object_auto_limit);
 
        if (!loose_object_auto_limit)
                return 0;
@@ -1415,8 +1415,8 @@ static int incremental_repack_auto_condition(struct gc_config *cfg UNUSED)
        if (!the_repository->settings.core_multi_pack_index)
                return 0;
 
-       git_config_get_int("maintenance.incremental-repack.auto",
-                          &incremental_repack_auto_limit);
+       repo_config_get_int(the_repository, "maintenance.incremental-repack.auto",
+                           &incremental_repack_auto_limit);
 
        if (!incremental_repack_auto_limit)
                return 0;
index 89739bee9b048f32053aa8843cf96720a44b9112..2490c47daaff8e60a3650132364c59ae77a09e14 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_int(const char *key, int *dest)
-{
-       return repo_config_get_int(the_repository, key, dest);
-}
-
 static inline int git_config_get_ulong(const char *key, unsigned long *dest)
 {
        return repo_config_get_ulong(the_repository, key, dest);
index 04768087879ad0896320f82bf5bb6c88e93b3626..1f184efb3c9c60909f042290c9153380609c1d07 100644 (file)
@@ -1901,8 +1901,8 @@ static int fetch_pack_config_cb(const char *var, const char *value,
 
 static void fetch_pack_config(void)
 {
-       git_config_get_int("fetch.unpacklimit", &fetch_unpack_limit);
-       git_config_get_int("transfer.unpacklimit", &transfer_unpack_limit);
+       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);
index 98b2b476f086842e67509a9bc0044bfec5fd12fd..d07dc18967ae339a4c023e36a18285ac5c787e7c 100644 (file)
@@ -43,7 +43,7 @@ static int fsmonitor_hook_version(void)
 {
        int hook_version;
 
-       if (git_config_get_int("core.fsmonitorhookversion", &hook_version))
+       if (repo_config_get_int(the_repository, "core.fsmonitorhookversion", &hook_version))
                return -1;
 
        if (hook_version == HOOK_INTERFACE_VERSION1 ||
index 29789579c9b12279a80e802bc9b5ed5440ddbfc3..45fd41f8dfdd2d5bb5aee8261103959e72b80f70 100644 (file)
@@ -5353,9 +5353,9 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
 {
        char *value = NULL;
        int renormalize = 0;
-       git_config_get_int("merge.verbosity", &opt->verbosity);
-       git_config_get_int("diff.renamelimit", &opt->rename_limit);
-       git_config_get_int("merge.renamelimit", &opt->rename_limit);
+       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);
        opt->renormalize = renormalize;
        if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
index 57c2dcaa8f60a179333f2b57be3c77c18fcc5ddd..fba6aa65a6e8524fcf829c0f2fb389146b643e22 100644 (file)
@@ -57,12 +57,12 @@ void get_parallel_checkout_configs(int *num_workers, int *threshold)
                return;
        }
 
-       if (git_config_get_int("checkout.workers", num_workers))
+       if (repo_config_get_int(the_repository, "checkout.workers", num_workers))
                *num_workers = DEFAULT_NUM_WORKERS;
        else if (*num_workers < 1)
                *num_workers = online_cpus();
 
-       if (git_config_get_int("checkout.thresholdForParallelism", threshold))
+       if (repo_config_get_int(the_repository, "checkout.thresholdForParallelism", threshold))
                *threshold = DEFAULT_THRESHOLD_FOR_PARALLELISM;
 }
 
diff --git a/refs.c b/refs.c
index 73913b6627be958e3d981178a93a4a0abbacfd7a..777cbd34ebcb398adebf318a28d50c10a6fb54e2 100644 (file)
--- a/refs.c
+++ b/refs.c
@@ -945,7 +945,7 @@ long get_files_ref_lock_timeout_ms(void)
        static int timeout_ms = 100;
 
        if (!configured) {
-               git_config_get_int("core.filesreflocktimeout", &timeout_ms);
+               repo_config_get_int(the_repository, "core.filesreflocktimeout", &timeout_ms);
                configured = 1;
        }
 
index 7fd73a0e6da3b5a4db630730f6e50c55e38747eb..7dd26726b1e987e4fc4809231b6abbce7568b35c 100644 (file)
@@ -1228,7 +1228,7 @@ int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err)
        static int timeout_value = 1000;
 
        if (!timeout_configured) {
-               git_config_get_int("core.packedrefstimeout", &timeout_value);
+               repo_config_get_int(the_repository, "core.packedrefstimeout", &timeout_value);
                timeout_configured = 1;
        }
 
index f3bada39b4075b2e5e67e0c318e42a2b9398da14..f8d9bb69df8263fd02ea1bcf1b9b5924d19b41e8 100644 (file)
@@ -5834,7 +5834,7 @@ static int make_script_with_merges(struct pretty_print_context *pp,
                *cmd_reset = abbr ? "t" : "reset",
                *cmd_merge = abbr ? "m" : "merge";
 
-       git_config_get_int("rebase.maxlabellength", &state.max_label_length);
+       repo_config_get_int(the_repository, "rebase.maxlabellength", &state.max_label_length);
 
        oidmap_init(&commit2todo, 0);
        oidmap_init(&state.commit2label, 0);
index 30e70f1a6c2310aba21a8cae769dbf4f9e19ae8e..ce1e333051676e3f414ca0cf9ab59e834af43a25 100644 (file)
@@ -155,7 +155,7 @@ int cmd__config(int argc, const char **argv)
                        BUG("Key \"%s\" has unknown return %d", argv[2], ret);
                goto exit1;
        } else if (argc == 3 && !strcmp(argv[1], "get_int")) {
-               if (!git_config_get_int(argv[2], &val)) {
+               if (!repo_config_get_int(the_repository, argv[2], &val)) {
                        printf("%d\n", val);
                        goto exit0;
                } else {