summaryrefslogtreecommitdiff
path: root/rerere.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-08-19 18:43:39 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-22 21:51:02 (GMT)
commit6e96cb5286105bbcf19d5c47e45334ef9a75d09d (patch)
treef9baa8d520f35b823146ff8947e7716ae843d665 /rerere.c
parent5ea82279c066f51d446b344e82492a3554409d7d (diff)
downloadgit-6e96cb5286105bbcf19d5c47e45334ef9a75d09d.zip
git-6e96cb5286105bbcf19d5c47e45334ef9a75d09d.tar.gz
git-6e96cb5286105bbcf19d5c47e45334ef9a75d09d.tar.bz2
rerere: allow approxidate in gc.rerereResolved/gc.rerereUnresolved
These two configuration variables are described in the documentation to take an expiry period expressed in the number of days: gc.rerereResolved:: Records of conflicted merge you resolved earlier are kept for this many days when 'git rerere gc' is run. The default is 60 days. gc.rerereUnresolved:: Records of conflicted merge you have not resolved are kept for this many days when 'git rerere gc' is run. The default is 15 days. There is no strong reason not to allow a more general "approxidate" expiry specification, e.g. "5.days.ago", or "never". Rename the config_get_expiry() helper introduced in the previous step to git_config_get_expiry_in_days() and move it to a more generic place, config.c, and use date.c::parse_expiry_date() to do so. Give it an ability to allow the caller to tell among three cases (i.e. there is no "gc.rerereResolved" config, there is and it is correctly parsed into the *expiry variable, and there was an error in parsing the given value). The current caller can work correctly without using the return value, though. In the future, we may find other variables that only allow an integer that specifies "this many days" or other unit of time, and when it happens we may need to drop "_days" suffix from the name of the function and instead pass the "scale" value as another parameter. But this will do for now. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'rerere.c')
-rw-r--r--rerere.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/rerere.c b/rerere.c
index f0b4bce..d772356 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1176,16 +1176,6 @@ static void prune_one(struct rerere_id *id,
unlink_rr_item(id);
}
-static void config_get_expiry(const char *key, timestamp_t *cutoff, timestamp_t now)
-{
- int days;
-
- if (!git_config_get_int(key, &days)) {
- const int scale = 86400;
- *cutoff = now - days * scale;
- }
-}
-
void rerere_gc(struct string_list *rr)
{
struct string_list to_remove = STRING_LIST_INIT_DUP;
@@ -1199,8 +1189,8 @@ void rerere_gc(struct string_list *rr)
if (setup_rerere(rr, 0) < 0)
return;
- config_get_expiry("gc.rerereresolved", &cutoff_resolve, now);
- config_get_expiry("gc.rerereunresolved", &cutoff_noresolve, now);
+ git_config_get_expiry_in_days("gc.rerereresolved", &cutoff_resolve, now);
+ git_config_get_expiry_in_days("gc.rerereunresolved", &cutoff_noresolve, now);
git_config(git_default_config, NULL);
dir = opendir(git_path("rr-cache"));
if (!dir)