config: drop `git_config_get_int()` wrapper

In 036876a106 (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>
maint
Patrick Steinhardt 2025-07-23 16:08:30 +02:00 committed by Junio C Hamano
parent cba3c02591
commit 3fda14d86d
13 changed files with 31 additions and 36 deletions

View 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)

View 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);

View 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");

View 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;

View File

@ -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);

View 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);

View 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 ||

View 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)) {

View 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;
}


2
refs.c
View File

@ -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;
}


View 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;
}


View 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);

View 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 {