config: pass repo to `git_config_get_index_threads()`

Refactor `git_config_get_index_threads()` to accept a `struct repository` such that we can get rid of the implicit dependency on `the_repository`. Rename the function accordingly. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Aug 13, 2024 at 11:13 UTC 1870cc30d4c0652ac97e75035c5cb43d7caebbfa
3 files changed +7 -7
config.c
+2 -2
@@ -2826,7 +2826,7 @@ int git_config_get_max_percent_split_change(void)
2826 return -1; /* default value */
2827 }
2828
2829 -int git_config_get_index_threads(int *dest)
2829 +int repo_config_get_index_threads(struct repository *r, int *dest)
2830 {
2831 int is_bool, val;
2832
@@ -2836,7 +2836,7 @@ int git_config_get_index_threads(int *dest)
2836 return 0;
2837 }
2838
2839 - if (!git_config_get_bool_or_int("index.threads", &is_bool, &val)) {
2839 + if (!repo_config_get_bool_or_int(r, "index.threads", &is_bool, &val)) {
2840 if (is_bool)
2841 *dest = val ? 0 : 1;
2842 else
config.h
+1 -1
@@ -710,7 +710,7 @@ int git_config_get_maybe_bool(const char *key, int *dest);
710 */
711 int git_config_get_pathname(const char *key, char **dest);
712
713 -int git_config_get_index_threads(int *dest);
713 +int repo_config_get_index_threads(struct repository *r, int *dest);
714 int git_config_get_split_index(void);
715 int git_config_get_max_percent_split_change(void);
716
read-cache.c
+4 -4
@@ -2267,7 +2267,7 @@ int do_read_index(struct index_state *istate, const char *path, int must_exist)
2267
2268 src_offset = sizeof(*hdr);
2269
2270 - if (git_config_get_index_threads(&nr_threads))
2270 + if (repo_config_get_index_threads(the_repository, &nr_threads))
2271 nr_threads = 1;
2272
2273 /* TODO: does creating more threads than cores help? */
@@ -2787,7 +2787,7 @@ static int record_eoie(void)
2787 * used for threading is written by default if the user
2788 * explicitly requested threaded index reads.
2789 */
2790 - return !git_config_get_index_threads(&val) && val != 1;
2790 + return !repo_config_get_index_threads(the_repository, &val) && val != 1;
2791 }
2792
2793 static int record_ieot(void)
@@ -2802,7 +2802,7 @@ static int record_ieot(void)
2802 * written by default if the user explicitly requested
2803 * threaded index reads.
2804 */
2805 - return !git_config_get_index_threads(&val) && val != 1;
2805 + return !repo_config_get_index_threads(the_repository, &val) && val != 1;
2806 }
2807
2808 enum write_extensions {
@@ -2875,7 +2875,7 @@ static int do_write_index(struct index_state *istate, struct tempfile *tempfile,
2875
2876 hashwrite(f, &hdr, sizeof(hdr));
2877
2878 - if (!HAVE_THREADS || git_config_get_index_threads(&nr_threads))
2878 + if (!HAVE_THREADS || repo_config_get_index_threads(the_repository, &nr_threads))
2879 nr_threads = 1;
2880
2881 if (nr_threads != 1 && record_ieot()) {