config: pass repo to `git_config_get_split_index()`

Refactor `git_config_get_split_index()` 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 be7537e6a9efc5cf4d5378dddfa9fcb76f9ad775
4 files changed +6 -6
builtin/update-index.c
+2 -2
@@ -1156,7 +1156,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1156 end_odb_transaction();
1157
1158 if (split_index > 0) {
1159 - if (git_config_get_split_index() == 0)
1159 + if (repo_config_get_split_index(the_repository) == 0)
1160 warning(_("core.splitIndex is set to false; "
1161 "remove or change it, if you really want to "
1162 "enable split index"));
@@ -1165,7 +1165,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
1165 else
1166 add_split_index(the_repository->index);
1167 } else if (!split_index) {
1168 - if (git_config_get_split_index() == 1)
1168 + if (repo_config_get_split_index(the_repository) == 1)
1169 warning(_("core.splitIndex is set to true; "
1170 "remove or change it, if you really want to "
1171 "disable split index"));
config.c
+2 -2
@@ -2801,11 +2801,11 @@ int git_config_get_expiry_in_days(const char *key, timestamp_t *expiry, timestam
2801 return -1; /* thing exists but cannot be parsed */
2802 }
2803
2804 -int git_config_get_split_index(void)
2804 +int repo_config_get_split_index(struct repository *r)
2805 {
2806 int val;
2807
2808 - if (!git_config_get_maybe_bool("core.splitindex", &val))
2808 + if (!repo_config_get_maybe_bool(r, "core.splitindex", &val))
2809 return val;
2810
2811 return -1; /* default value */
config.h
+1 -1
@@ -711,7 +711,7 @@ int git_config_get_maybe_bool(const char *key, int *dest);
711 int git_config_get_pathname(const char *key, char **dest);
712
713 int repo_config_get_index_threads(struct repository *r, int *dest);
714 -int git_config_get_split_index(void);
714 +int repo_config_get_split_index(struct repository *r);
715 int git_config_get_max_percent_split_change(void);
716
717 /* This dies if the configured or default date is in the future */
read-cache.c
+1 -1
@@ -1945,7 +1945,7 @@ static void tweak_untracked_cache(struct index_state *istate)
1945
1946 static void tweak_split_index(struct index_state *istate)
1947 {
1948 - switch (git_config_get_split_index()) {
1948 + switch (repo_config_get_split_index(the_repository)) {
1949 case -1: /* unset: do nothing */
1950 break;
1951 case 0: /* false */