Skip to content

Commit 3fda14d

Browse files
pks-tgitster
authored andcommitted
config: drop git_config_get_int() 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_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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent cba3c02 commit 3fda14d

File tree

13 files changed

+31
-36
lines changed

13 files changed

+31
-36
lines changed

builtin/credential-store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static void rewrite_credential_file(const char *fn, struct credential *c,
6666
{
6767
int timeout_ms = 1000;
6868

69-
git_config_get_int("credentialstore.locktimeoutms", &timeout_ms);
69+
repo_config_get_int(the_repository, "credentialstore.locktimeoutms", &timeout_ms);
7070
if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0)
7171
die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms);
7272
if (extra)

builtin/fast-import.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3527,7 +3527,7 @@ static void git_pack_config(void)
35273527
if (max_depth > MAX_DEPTH)
35283528
max_depth = MAX_DEPTH;
35293529
}
3530-
if (!git_config_get_int("pack.indexversion", &indexversion_value)) {
3530+
if (!repo_config_get_int(the_repository, "pack.indexversion", &indexversion_value)) {
35313531
pack_idx_opts.version = indexversion_value;
35323532
if (pack_idx_opts.version > 2)
35333533
git_die_config(the_repository, "pack.indexversion",
@@ -3536,9 +3536,9 @@ static void git_pack_config(void)
35363536
if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value))
35373537
max_packsize = packsizelimit_value;
35383538

3539-
if (!git_config_get_int("fastimport.unpacklimit", &limit))
3539+
if (!repo_config_get_int(the_repository, "fastimport.unpacklimit", &limit))
35403540
unpack_limit = limit;
3541-
else if (!git_config_get_int("transfer.unpacklimit", &limit))
3541+
else if (!repo_config_get_int(the_repository, "transfer.unpacklimit", &limit))
35423542
unpack_limit = limit;
35433543

35443544
repo_config(the_repository, git_default_config, NULL);

builtin/fetch.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,12 +2683,12 @@ int cmd_fetch(int argc,
26832683
* but respect config settings disabling it.
26842684
*/
26852685
int opt_val;
2686-
if (git_config_get_int("gc.autopacklimit", &opt_val))
2686+
if (repo_config_get_int(the_repository, "gc.autopacklimit", &opt_val))
26872687
opt_val = -1;
26882688
if (opt_val != 0)
26892689
git_config_push_parameter("gc.autoPackLimit=1");
26902690

2691-
if (git_config_get_int("maintenance.incremental-repack.auto", &opt_val))
2691+
if (repo_config_get_int(the_repository, "maintenance.incremental-repack.auto", &opt_val))
26922692
opt_val = -1;
26932693
if (opt_val != 0)
26942694
git_config_push_parameter("maintenance.incremental-repack.auto=-1");

builtin/gc.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,10 @@ static void gc_config(struct gc_config *cfg)
189189
gc_config_is_timestamp_never("gc.reflogexpireunreachable"))
190190
cfg->prune_reflogs = 0;
191191

192-
git_config_get_int("gc.aggressivewindow", &cfg->aggressive_window);
193-
git_config_get_int("gc.aggressivedepth", &cfg->aggressive_depth);
194-
git_config_get_int("gc.auto", &cfg->gc_auto_threshold);
195-
git_config_get_int("gc.autopacklimit", &cfg->gc_auto_pack_limit);
192+
repo_config_get_int(the_repository, "gc.aggressivewindow", &cfg->aggressive_window);
193+
repo_config_get_int(the_repository, "gc.aggressivedepth", &cfg->aggressive_depth);
194+
repo_config_get_int(the_repository, "gc.auto", &cfg->gc_auto_threshold);
195+
repo_config_get_int(the_repository, "gc.autopacklimit", &cfg->gc_auto_pack_limit);
196196
git_config_get_bool("gc.autodetach", &cfg->detach_auto);
197197
git_config_get_bool("gc.cruftpacks", &cfg->cruft_packs);
198198
git_config_get_ulong("gc.maxcruftsize", &cfg->max_cruft_size);
@@ -332,7 +332,7 @@ static int reflog_expire_condition(struct gc_config *cfg UNUSED)
332332
};
333333
int limit = 100;
334334

335-
git_config_get_int("maintenance.reflog-expire.auto", &limit);
335+
repo_config_get_int(the_repository, "maintenance.reflog-expire.auto", &limit);
336336
if (!limit)
337337
return 0;
338338
if (limit < 0)
@@ -378,7 +378,7 @@ static int worktree_prune_condition(struct gc_config *cfg)
378378
struct dirent *d;
379379
DIR *dir = NULL;
380380

381-
git_config_get_int("maintenance.worktree-prune.auto", &limit);
381+
repo_config_get_int(the_repository, "maintenance.worktree-prune.auto", &limit);
382382
if (limit <= 0) {
383383
should_prune = limit < 0;
384384
goto out;
@@ -423,7 +423,7 @@ static int rerere_gc_condition(struct gc_config *cfg UNUSED)
423423
int should_gc = 0, limit = 1;
424424
DIR *dir = NULL;
425425

426-
git_config_get_int("maintenance.rerere-gc.auto", &limit);
426+
repo_config_get_int(the_repository, "maintenance.rerere-gc.auto", &limit);
427427
if (limit <= 0) {
428428
should_gc = limit < 0;
429429
goto out;
@@ -1161,8 +1161,8 @@ static int should_write_commit_graph(struct gc_config *cfg UNUSED)
11611161

11621162
data.num_not_in_graph = 0;
11631163
data.limit = 100;
1164-
git_config_get_int("maintenance.commit-graph.auto",
1165-
&data.limit);
1164+
repo_config_get_int(the_repository, "maintenance.commit-graph.auto",
1165+
&data.limit);
11661166

11671167
if (!data.limit)
11681168
return 0;
@@ -1300,8 +1300,8 @@ static int loose_object_auto_condition(struct gc_config *cfg UNUSED)
13001300
{
13011301
int count = 0;
13021302

1303-
git_config_get_int("maintenance.loose-objects.auto",
1304-
&loose_object_auto_limit);
1303+
repo_config_get_int(the_repository, "maintenance.loose-objects.auto",
1304+
&loose_object_auto_limit);
13051305

13061306
if (!loose_object_auto_limit)
13071307
return 0;
@@ -1415,8 +1415,8 @@ static int incremental_repack_auto_condition(struct gc_config *cfg UNUSED)
14151415
if (!the_repository->settings.core_multi_pack_index)
14161416
return 0;
14171417

1418-
git_config_get_int("maintenance.incremental-repack.auto",
1419-
&incremental_repack_auto_limit);
1418+
repo_config_get_int(the_repository, "maintenance.incremental-repack.auto",
1419+
&incremental_repack_auto_limit);
14201420

14211421
if (!incremental_repack_auto_limit)
14221422
return 0;

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_int(const char *key, int *dest)
723-
{
724-
return repo_config_get_int(the_repository, key, dest);
725-
}
726-
727722
static inline int git_config_get_ulong(const char *key, unsigned long *dest)
728723
{
729724
return repo_config_get_ulong(the_repository, key, dest);

fetch-pack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1901,8 +1901,8 @@ static int fetch_pack_config_cb(const char *var, const char *value,
19011901

19021902
static void fetch_pack_config(void)
19031903
{
1904-
git_config_get_int("fetch.unpacklimit", &fetch_unpack_limit);
1905-
git_config_get_int("transfer.unpacklimit", &transfer_unpack_limit);
1904+
repo_config_get_int(the_repository, "fetch.unpacklimit", &fetch_unpack_limit);
1905+
repo_config_get_int(the_repository, "transfer.unpacklimit", &transfer_unpack_limit);
19061906
git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta);
19071907
git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects);
19081908
git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);

fsmonitor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int fsmonitor_hook_version(void)
4343
{
4444
int hook_version;
4545

46-
if (git_config_get_int("core.fsmonitorhookversion", &hook_version))
46+
if (repo_config_get_int(the_repository, "core.fsmonitorhookversion", &hook_version))
4747
return -1;
4848

4949
if (hook_version == HOOK_INTERFACE_VERSION1 ||

merge-ort.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5353,9 +5353,9 @@ static void merge_recursive_config(struct merge_options *opt, int ui)
53535353
{
53545354
char *value = NULL;
53555355
int renormalize = 0;
5356-
git_config_get_int("merge.verbosity", &opt->verbosity);
5357-
git_config_get_int("diff.renamelimit", &opt->rename_limit);
5358-
git_config_get_int("merge.renamelimit", &opt->rename_limit);
5356+
repo_config_get_int(the_repository, "merge.verbosity", &opt->verbosity);
5357+
repo_config_get_int(the_repository, "diff.renamelimit", &opt->rename_limit);
5358+
repo_config_get_int(the_repository, "merge.renamelimit", &opt->rename_limit);
53595359
git_config_get_bool("merge.renormalize", &renormalize);
53605360
opt->renormalize = renormalize;
53615361
if (!repo_config_get_string(the_repository, "diff.renames", &value)) {

parallel-checkout.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ void get_parallel_checkout_configs(int *num_workers, int *threshold)
5757
return;
5858
}
5959

60-
if (git_config_get_int("checkout.workers", num_workers))
60+
if (repo_config_get_int(the_repository, "checkout.workers", num_workers))
6161
*num_workers = DEFAULT_NUM_WORKERS;
6262
else if (*num_workers < 1)
6363
*num_workers = online_cpus();
6464

65-
if (git_config_get_int("checkout.thresholdForParallelism", threshold))
65+
if (repo_config_get_int(the_repository, "checkout.thresholdForParallelism", threshold))
6666
*threshold = DEFAULT_THRESHOLD_FOR_PARALLELISM;
6767
}
6868

refs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ long get_files_ref_lock_timeout_ms(void)
945945
static int timeout_ms = 100;
946946

947947
if (!configured) {
948-
git_config_get_int("core.filesreflocktimeout", &timeout_ms);
948+
repo_config_get_int(the_repository, "core.filesreflocktimeout", &timeout_ms);
949949
configured = 1;
950950
}
951951

0 commit comments

Comments
 (0)