Skip to content

Commit 44ebcd6

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 87aace1 commit 44ebcd6

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,13 +2779,14 @@ int repo_config_get_expiry(struct repository *r, const char *key, const char **o
27792779
return ret;
27802780
}
27812781

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)
27832784
{
27842785
const char *expiry_string;
27852786
intmax_t days;
27862787
timestamp_t when;
27872788

2788-
if (git_config_get_string_tmp(key, &expiry_string))
2789+
if (repo_config_get_string_tmp(r, key, &expiry_string))
27892790
return 1; /* no such thing */
27902791

27912792
if (git_parse_signed(expiry_string, &days, maximum_signed_value_of_type(int))) {

config.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,8 @@ int repo_config_get_max_percent_split_change(struct repository *r);
718718
int repo_config_get_expiry(struct repository *r, const char *key, const char **output);
719719

720720
/* 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);
722723

723724
/**
724725
* First prints the error message specified by the caller in `err` and then

rerere.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,8 +1203,10 @@ void rerere_gc(struct repository *r, struct string_list *rr)
12031203
if (setup_rerere(r, rr, 0) < 0)
12041204
return;
12051205

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);
12081210
git_config(git_default_config, NULL);
12091211
dir = opendir(git_path("rr-cache"));
12101212
if (!dir)

0 commit comments

Comments
 (0)