From 77d67977cac46aa6c07c66ce9e2470f00feb9d20 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Mon, 27 Feb 2017 19:00:13 +0100 Subject: config: add git_config_get_expiry() from gc.c This function will be used in a following commit to get the expiration time of the shared index files from the config, and it is generic enough to be put in "config.c". Signed-off-by: Christian Couder Signed-off-by: Junio C Hamano --- config.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'config.c') diff --git a/config.c b/config.c index cf212785bb..d6c8f8f3ba 100644 --- a/config.c +++ b/config.c @@ -1685,6 +1685,19 @@ int git_config_get_pathname(const char *key, const char **dest) return ret; } +int git_config_get_expiry(const char *key, const char **output) +{ + int ret = git_config_get_string_const(key, output); + if (ret) + return ret; + if (strcmp(*output, "now")) { + unsigned long now = approxidate("now"); + if (approxidate(*output) >= now) + git_die_config(key, _("Invalid %s: '%s'"), key, *output); + } + return ret; +} + int git_config_get_untracked_cache(void) { int val = -1; -- cgit v1.2.3