]> git.ipfire.org Git - thirdparty/git.git/commitdiff
config: pass repo to `git_config_get_expiry_in_days()`
authorPatrick Steinhardt <ps@pks.im>
Tue, 13 Aug 2024 09:14:03 +0000 (11:14 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 13 Aug 2024 17:01:03 +0000 (10:01 -0700)
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>
config.c
config.h
rerere.c

index 4138dc50ce8e2e40d154555dae75b61c2707fa7e..33d9af29c8031eccef5fcc503f0e32c4a268b1f3 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2779,13 +2779,14 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
        return ret;
 }
 
-int git_config_get_expiry_in_days(const char *key, timestamp_t *expiry, timestamp_t now)
+int repo_config_get_expiry_in_days(struct repository *r, const char *key,
+                                  timestamp_t *expiry, timestamp_t now)
 {
        const char *expiry_string;
        intmax_t days;
        timestamp_t when;
 
-       if (git_config_get_string_tmp(key, &expiry_string))
+       if (repo_config_get_string_tmp(r, key, &expiry_string))
                return 1; /* no such thing */
 
        if (git_parse_signed(expiry_string, &days, maximum_signed_value_of_type(int))) {
index 7674617a1db9959fb05ba4fc17fcf1efd03a3df4..3a5016afea6026c931e6f9ae4c0eea3f125be301 100644 (file)
--- a/config.h
+++ b/config.h
@@ -718,7 +718,8 @@ int repo_config_get_max_percent_split_change(struct repository *r);
 int repo_config_get_expiry(struct repository *r, const char *key, const char **output);
 
 /* parse either "this many days" integer, or "5.days.ago" approxidate */
-int git_config_get_expiry_in_days(const char *key, timestamp_t *, timestamp_t now);
+int repo_config_get_expiry_in_days(struct repository *r, const char *key,
+                                  timestamp_t *, timestamp_t now);
 
 /**
  * First prints the error message specified by the caller in `err` and then
index 3a3888cce2074227f6cb49d2654d7154aeafed67..578a4fe378c62357619844af006a5aa9b5ec736d 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -1203,8 +1203,10 @@ void rerere_gc(struct repository *r, struct string_list *rr)
        if (setup_rerere(r, rr, 0) < 0)
                return;
 
-       git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
-       git_config_get_expiry_in_days("gc.rerereunresolved", &cutoff_noresolve, now);
+       repo_config_get_expiry_in_days(the_repository, "gc.rerereresolved",
+                                      &cutoff_resolve, now);
+       repo_config_get_expiry_in_days(the_repository, "gc.rerereunresolved",
+                                      &cutoff_noresolve, now);
        git_config(git_default_config, NULL);
        dir = opendir(git_path("rr-cache"));
        if (!dir)