diff mbox series

[13/20] config: pass repo to `git_config_get_expiry()`

Message ID 412cc514e8f4b40c45d1c80224bba72688c4c576.1723013714.git.ps@pks.im (mailing list archive)
State Superseded
Headers show
Series Stop using `the_repository` in "config.c" | expand

Commit Message

Patrick Steinhardt Aug. 7, 2024, 6:57 a.m. UTC
Refactor `git_config_get_expiry()` 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>
---
 builtin/gc.c | 6 +++---
 config.c     | 4 ++--
 config.h     | 2 +-
 read-cache.c | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/builtin/gc.c b/builtin/gc.c
index 2ca6288c6b..dc87c65906 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -167,9 +167,9 @@  static void gc_config(void)
 	git_config_get_bool("gc.autodetach", &detach_auto);
 	git_config_get_bool("gc.cruftpacks", &cruft_packs);
 	git_config_get_ulong("gc.maxcruftsize", &max_cruft_size);
-	git_config_get_expiry("gc.pruneexpire", &prune_expire);
-	git_config_get_expiry("gc.worktreepruneexpire", &prune_worktrees_expire);
-	git_config_get_expiry("gc.logexpiry", &gc_log_expire);
+	repo_config_get_expiry(the_repository, "gc.pruneexpire", &prune_expire);
+	repo_config_get_expiry(the_repository, "gc.worktreepruneexpire", &prune_worktrees_expire);
+	repo_config_get_expiry(the_repository, "gc.logexpiry", &gc_log_expire);
 
 	git_config_get_ulong("gc.bigpackthreshold", &big_pack_threshold);
 	git_config_get_ulong("pack.deltacachesize", &max_delta_cache_size);
diff --git a/config.c b/config.c
index f1d2fb6d4c..4138dc50ce 100644
--- a/config.c
+++ b/config.c
@@ -2766,9 +2766,9 @@  int git_config_get_pathname(const char *key, char **dest)
 	return repo_config_get_pathname(the_repository, key, dest);
 }
 
-int git_config_get_expiry(const char *key, const char **output)
+int repo_config_get_expiry(struct repository *r, const char *key, const char **output)
 {
-	int ret = git_config_get_string(key, (char **)output);
+	int ret = repo_config_get_string(r, key, (char **)output);
 	if (ret)
 		return ret;
 	if (strcmp(*output, "now")) {
diff --git a/config.h b/config.h
index dd7127b8e9..7674617a1d 100644
--- a/config.h
+++ b/config.h
@@ -715,7 +715,7 @@  int repo_config_get_split_index(struct repository *r);
 int repo_config_get_max_percent_split_change(struct repository *r);
 
 /* This dies if the configured or default date is in the future */
-int git_config_get_expiry(const char *key, const char **output);
+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);
diff --git a/read-cache.c b/read-cache.c
index 1e52db7f36..18394d7180 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -3184,8 +3184,8 @@  static unsigned long get_shared_index_expire_date(void)
 	static int shared_index_expire_date_prepared;
 
 	if (!shared_index_expire_date_prepared) {
-		git_config_get_expiry("splitindex.sharedindexexpire",
-				      &shared_index_expire);
+		repo_config_get_expiry(the_repository, "splitindex.sharedindexexpire",
+				       &shared_index_expire);
 		shared_index_expire_date = approxidate(shared_index_expire);
 		shared_index_expire_date_prepared = 1;
 	}