config: pass repo to `git_config_get_expiry_in_days()`

Refactor `git_config_get_expiry_in_days()` 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:14 UTC 44ebcd6254ce9e42eeaa70b67750efb356157914
3 files changed +9 -5
config.c
+3 -2
@@ -2779,13 +2779,14 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
2779 return ret;
2780 }
2781
2782 -int git_config_get_expiry_in_days(const char *key, timestamp_t *expiry, timestamp_t now)
2782 +int repo_config_get_expiry_in_days(struct repository *r, const char *key,
2783 + timestamp_t *expiry, timestamp_t now)
2784 {
2785 const char *expiry_string;
2786 intmax_t days;
2787 timestamp_t when;
2788
2788 - if (git_config_get_string_tmp(key, &expiry_string))
2789 + if (repo_config_get_string_tmp(r, key, &expiry_string))
2790 return 1; /* no such thing */
2791
2792 if (git_parse_signed(expiry_string, &days, maximum_signed_value_of_type(int))) {
config.h
+2 -1
@@ -718,7 +718,8 @@ int repo_config_get_max_percent_split_change(struct repository *r);
718 int repo_config_get_expiry(struct repository *r, const char *key, const char **output);
719
720 /* parse either "this many days" integer, or "5.days.ago" approxidate */
721 -int git_config_get_expiry_in_days(const char *key, timestamp_t *, timestamp_t now);
721 +int repo_config_get_expiry_in_days(struct repository *r, const char *key,
722 + timestamp_t *, timestamp_t now);
723
724 /**
725 * First prints the error message specified by the caller in `err` and then
rerere.c
+4 -2
@@ -1203,8 +1203,10 @@ void rerere_gc(struct repository *r, struct string_list *rr)
1203 if (setup_rerere(r, rr, 0) < 0)
1204 return;
1205
1206 - git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
1207 - git_config_get_expiry_in_days("gc.rerereunresolved", &cutoff_noresolve, now);
1206 + repo_config_get_expiry_in_days(the_repository, "gc.rerereresolved",
1207 + &cutoff_resolve, now);
1208 + repo_config_get_expiry_in_days(the_repository, "gc.rerereunresolved",
1209 + &cutoff_noresolve, now);
1210 git_config(git_default_config, NULL);
1211 dir = opendir(git_path("rr-cache"));
1212 if (!dir)