summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorLibravatar Christian Couder <christian.couder@gmail.com>2017-02-27 19:00:13 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-03-01 13:34:54 -0800
commit77d67977cac46aa6c07c66ce9e2470f00feb9d20 (patch)
tree580440bf17327f2d08c337d6f05cbb0836895c26 /config.c
parentread-cache: touch shared index files when used (diff)
downloadtgif-77d67977cac46aa6c07c66ce9e2470f00feb9d20.tar.xz
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 <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c13
1 files changed, 13 insertions, 0 deletions
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;