diff mbox series

[14/20] config: pass repo to `git_config_get_expiry_in_days()`

Message ID cf7942479f75d95dcd8606b0947a8897ae60da60.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_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>
---
 config.c | 5 +++--
 config.h | 3 ++-
 rerere.c | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

Comments

Justin Tobler Aug. 9, 2024, 8:21 p.m. UTC | #1
On 24/08/07 08:57AM, Patrick Steinhardt wrote:
> 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>
> ---
[snip]
> -	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);

non-blocking: Do we want to fold these lines?

>  	git_config(git_default_config, NULL);
>  	dir = opendir(git_path("rr-cache"));
>  	if (!dir)
Junio C Hamano Aug. 9, 2024, 9:14 p.m. UTC | #2
Justin Tobler <jltobler@gmail.com> writes:

> On 24/08/07 08:57AM, Patrick Steinhardt wrote:
>> 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>
>> ---
> [snip]
>> -	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);
>
> non-blocking: Do we want to fold these lines?

Yes, if we are going to see another iteration for other reasons.
diff mbox series

Patch

diff --git a/config.c b/config.c
index 4138dc50ce..33d9af29c8 100644
--- 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))) {
diff --git a/config.h b/config.h
index 7674617a1d..3a5016afea 100644
--- 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
diff --git a/rerere.c b/rerere.c
index 3a3888cce2..bdd9fb2ff8 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1203,8 +1203,8 @@  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)