Git fork

config: drop `git_config_get_int()` wrapper

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>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
3fda14d8 cba3c025

+31 -36
+1 -1
builtin/credential-store.c
··· 66 { 67 int timeout_ms = 1000; 68 69 - git_config_get_int("credentialstore.locktimeoutms", &timeout_ms); 70 if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0) 71 die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms); 72 if (extra)
··· 66 { 67 int timeout_ms = 1000; 68 69 + repo_config_get_int(the_repository, "credentialstore.locktimeoutms", &timeout_ms); 70 if (hold_lock_file_for_update_timeout(&credential_lock, fn, 0, timeout_ms) < 0) 71 die_errno(_("unable to get credential storage lock in %d ms"), timeout_ms); 72 if (extra)
+3 -3
builtin/fast-import.c
··· 3527 if (max_depth > MAX_DEPTH) 3528 max_depth = MAX_DEPTH; 3529 } 3530 - if (!git_config_get_int("pack.indexversion", &indexversion_value)) { 3531 pack_idx_opts.version = indexversion_value; 3532 if (pack_idx_opts.version > 2) 3533 git_die_config(the_repository, "pack.indexversion", ··· 3536 if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value)) 3537 max_packsize = packsizelimit_value; 3538 3539 - if (!git_config_get_int("fastimport.unpacklimit", &limit)) 3540 unpack_limit = limit; 3541 - else if (!git_config_get_int("transfer.unpacklimit", &limit)) 3542 unpack_limit = limit; 3543 3544 repo_config(the_repository, git_default_config, NULL);
··· 3527 if (max_depth > MAX_DEPTH) 3528 max_depth = MAX_DEPTH; 3529 } 3530 + if (!repo_config_get_int(the_repository, "pack.indexversion", &indexversion_value)) { 3531 pack_idx_opts.version = indexversion_value; 3532 if (pack_idx_opts.version > 2) 3533 git_die_config(the_repository, "pack.indexversion", ··· 3536 if (!git_config_get_ulong("pack.packsizelimit", &packsizelimit_value)) 3537 max_packsize = packsizelimit_value; 3538 3539 + if (!repo_config_get_int(the_repository, "fastimport.unpacklimit", &limit)) 3540 unpack_limit = limit; 3541 + else if (!repo_config_get_int(the_repository, "transfer.unpacklimit", &limit)) 3542 unpack_limit = limit; 3543 3544 repo_config(the_repository, git_default_config, NULL);
+2 -2
builtin/fetch.c
··· 2683 * but respect config settings disabling it. 2684 */ 2685 int opt_val; 2686 - if (git_config_get_int("gc.autopacklimit", &opt_val)) 2687 opt_val = -1; 2688 if (opt_val != 0) 2689 git_config_push_parameter("gc.autoPackLimit=1"); 2690 2691 - if (git_config_get_int("maintenance.incremental-repack.auto", &opt_val)) 2692 opt_val = -1; 2693 if (opt_val != 0) 2694 git_config_push_parameter("maintenance.incremental-repack.auto=-1");
··· 2683 * but respect config settings disabling it. 2684 */ 2685 int opt_val; 2686 + if (repo_config_get_int(the_repository, "gc.autopacklimit", &opt_val)) 2687 opt_val = -1; 2688 if (opt_val != 0) 2689 git_config_push_parameter("gc.autoPackLimit=1"); 2690 2691 + if (repo_config_get_int(the_repository, "maintenance.incremental-repack.auto", &opt_val)) 2692 opt_val = -1; 2693 if (opt_val != 0) 2694 git_config_push_parameter("maintenance.incremental-repack.auto=-1");
+13 -13
builtin/gc.c
··· 189 gc_config_is_timestamp_never("gc.reflogexpireunreachable")) 190 cfg->prune_reflogs = 0; 191 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); 196 git_config_get_bool("gc.autodetach", &cfg->detach_auto); 197 git_config_get_bool("gc.cruftpacks", &cfg->cruft_packs); 198 git_config_get_ulong("gc.maxcruftsize", &cfg->max_cruft_size); ··· 332 }; 333 int limit = 100; 334 335 - git_config_get_int("maintenance.reflog-expire.auto", &limit); 336 if (!limit) 337 return 0; 338 if (limit < 0) ··· 378 struct dirent *d; 379 DIR *dir = NULL; 380 381 - git_config_get_int("maintenance.worktree-prune.auto", &limit); 382 if (limit <= 0) { 383 should_prune = limit < 0; 384 goto out; ··· 423 int should_gc = 0, limit = 1; 424 DIR *dir = NULL; 425 426 - git_config_get_int("maintenance.rerere-gc.auto", &limit); 427 if (limit <= 0) { 428 should_gc = limit < 0; 429 goto out; ··· 1161 1162 data.num_not_in_graph = 0; 1163 data.limit = 100; 1164 - git_config_get_int("maintenance.commit-graph.auto", 1165 - &data.limit); 1166 1167 if (!data.limit) 1168 return 0; ··· 1300 { 1301 int count = 0; 1302 1303 - git_config_get_int("maintenance.loose-objects.auto", 1304 - &loose_object_auto_limit); 1305 1306 if (!loose_object_auto_limit) 1307 return 0; ··· 1415 if (!the_repository->settings.core_multi_pack_index) 1416 return 0; 1417 1418 - git_config_get_int("maintenance.incremental-repack.auto", 1419 - &incremental_repack_auto_limit); 1420 1421 if (!incremental_repack_auto_limit) 1422 return 0;
··· 189 gc_config_is_timestamp_never("gc.reflogexpireunreachable")) 190 cfg->prune_reflogs = 0; 191 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); 196 git_config_get_bool("gc.autodetach", &cfg->detach_auto); 197 git_config_get_bool("gc.cruftpacks", &cfg->cruft_packs); 198 git_config_get_ulong("gc.maxcruftsize", &cfg->max_cruft_size); ··· 332 }; 333 int limit = 100; 334 335 + repo_config_get_int(the_repository, "maintenance.reflog-expire.auto", &limit); 336 if (!limit) 337 return 0; 338 if (limit < 0) ··· 378 struct dirent *d; 379 DIR *dir = NULL; 380 381 + repo_config_get_int(the_repository, "maintenance.worktree-prune.auto", &limit); 382 if (limit <= 0) { 383 should_prune = limit < 0; 384 goto out; ··· 423 int should_gc = 0, limit = 1; 424 DIR *dir = NULL; 425 426 + repo_config_get_int(the_repository, "maintenance.rerere-gc.auto", &limit); 427 if (limit <= 0) { 428 should_gc = limit < 0; 429 goto out; ··· 1161 1162 data.num_not_in_graph = 0; 1163 data.limit = 100; 1164 + repo_config_get_int(the_repository, "maintenance.commit-graph.auto", 1165 + &data.limit); 1166 1167 if (!data.limit) 1168 return 0; ··· 1300 { 1301 int count = 0; 1302 1303 + repo_config_get_int(the_repository, "maintenance.loose-objects.auto", 1304 + &loose_object_auto_limit); 1305 1306 if (!loose_object_auto_limit) 1307 return 0; ··· 1415 if (!the_repository->settings.core_multi_pack_index) 1416 return 0; 1417 1418 + repo_config_get_int(the_repository, "maintenance.incremental-repack.auto", 1419 + &incremental_repack_auto_limit); 1420 1421 if (!incremental_repack_auto_limit) 1422 return 0;
-5
config.h
··· 719 int lookup_config(const char **mapping, int nr_mapping, const char *var); 720 721 # 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 - 727 static inline int git_config_get_ulong(const char *key, unsigned long *dest) 728 { 729 return repo_config_get_ulong(the_repository, key, dest);
··· 719 int lookup_config(const char **mapping, int nr_mapping, const char *var); 720 721 # ifdef USE_THE_REPOSITORY_VARIABLE 722 static inline int git_config_get_ulong(const char *key, unsigned long *dest) 723 { 724 return repo_config_get_ulong(the_repository, key, dest);
+2 -2
fetch-pack.c
··· 1901 1902 static void fetch_pack_config(void) 1903 { 1904 - git_config_get_int("fetch.unpacklimit", &fetch_unpack_limit); 1905 - git_config_get_int("transfer.unpacklimit", &transfer_unpack_limit); 1906 git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta); 1907 git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects); 1908 git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
··· 1901 1902 static void fetch_pack_config(void) 1903 { 1904 + repo_config_get_int(the_repository, "fetch.unpacklimit", &fetch_unpack_limit); 1905 + repo_config_get_int(the_repository, "transfer.unpacklimit", &transfer_unpack_limit); 1906 git_config_get_bool("repack.usedeltabaseoffset", &prefer_ofs_delta); 1907 git_config_get_bool("fetch.fsckobjects", &fetch_fsck_objects); 1908 git_config_get_bool("transfer.fsckobjects", &transfer_fsck_objects);
+1 -1
fsmonitor.c
··· 43 { 44 int hook_version; 45 46 - if (git_config_get_int("core.fsmonitorhookversion", &hook_version)) 47 return -1; 48 49 if (hook_version == HOOK_INTERFACE_VERSION1 ||
··· 43 { 44 int hook_version; 45 46 + if (repo_config_get_int(the_repository, "core.fsmonitorhookversion", &hook_version)) 47 return -1; 48 49 if (hook_version == HOOK_INTERFACE_VERSION1 ||
+3 -3
merge-ort.c
··· 5353 { 5354 char *value = NULL; 5355 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); 5359 git_config_get_bool("merge.renormalize", &renormalize); 5360 opt->renormalize = renormalize; 5361 if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
··· 5353 { 5354 char *value = NULL; 5355 int renormalize = 0; 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); 5359 git_config_get_bool("merge.renormalize", &renormalize); 5360 opt->renormalize = renormalize; 5361 if (!repo_config_get_string(the_repository, "diff.renames", &value)) {
+2 -2
parallel-checkout.c
··· 57 return; 58 } 59 60 - if (git_config_get_int("checkout.workers", num_workers)) 61 *num_workers = DEFAULT_NUM_WORKERS; 62 else if (*num_workers < 1) 63 *num_workers = online_cpus(); 64 65 - if (git_config_get_int("checkout.thresholdForParallelism", threshold)) 66 *threshold = DEFAULT_THRESHOLD_FOR_PARALLELISM; 67 } 68
··· 57 return; 58 } 59 60 + if (repo_config_get_int(the_repository, "checkout.workers", num_workers)) 61 *num_workers = DEFAULT_NUM_WORKERS; 62 else if (*num_workers < 1) 63 *num_workers = online_cpus(); 64 65 + if (repo_config_get_int(the_repository, "checkout.thresholdForParallelism", threshold)) 66 *threshold = DEFAULT_THRESHOLD_FOR_PARALLELISM; 67 } 68
+1 -1
refs.c
··· 945 static int timeout_ms = 100; 946 947 if (!configured) { 948 - git_config_get_int("core.filesreflocktimeout", &timeout_ms); 949 configured = 1; 950 } 951
··· 945 static int timeout_ms = 100; 946 947 if (!configured) { 948 + repo_config_get_int(the_repository, "core.filesreflocktimeout", &timeout_ms); 949 configured = 1; 950 } 951
+1 -1
refs/packed-backend.c
··· 1228 static int timeout_value = 1000; 1229 1230 if (!timeout_configured) { 1231 - git_config_get_int("core.packedrefstimeout", &timeout_value); 1232 timeout_configured = 1; 1233 } 1234
··· 1228 static int timeout_value = 1000; 1229 1230 if (!timeout_configured) { 1231 + repo_config_get_int(the_repository, "core.packedrefstimeout", &timeout_value); 1232 timeout_configured = 1; 1233 } 1234
+1 -1
sequencer.c
··· 5834 *cmd_reset = abbr ? "t" : "reset", 5835 *cmd_merge = abbr ? "m" : "merge"; 5836 5837 - git_config_get_int("rebase.maxlabellength", &state.max_label_length); 5838 5839 oidmap_init(&commit2todo, 0); 5840 oidmap_init(&state.commit2label, 0);
··· 5834 *cmd_reset = abbr ? "t" : "reset", 5835 *cmd_merge = abbr ? "m" : "merge"; 5836 5837 + repo_config_get_int(the_repository, "rebase.maxlabellength", &state.max_label_length); 5838 5839 oidmap_init(&commit2todo, 0); 5840 oidmap_init(&state.commit2label, 0);
+1 -1
t/helper/test-config.c
··· 155 BUG("Key \"%s\" has unknown return %d", argv[2], ret); 156 goto exit1; 157 } else if (argc == 3 && !strcmp(argv[1], "get_int")) { 158 - if (!git_config_get_int(argv[2], &val)) { 159 printf("%d\n", val); 160 goto exit0; 161 } else {
··· 155 BUG("Key \"%s\" has unknown return %d", argv[2], ret); 156 goto exit1; 157 } else if (argc == 3 && !strcmp(argv[1], "get_int")) { 158 + if (!repo_config_get_int(the_repository, argv[2], &val)) { 159 printf("%d\n", val); 160 goto exit0; 161 } else {