summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2014-11-30 08:24:52 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-12-01 19:00:17 (GMT)
commit09dbb90b09f8f69f79951fed193230a3421dc9d9 (patch)
tree713c2fcb50de7b1748d34fff89057ca09d2af35b /builtin
parent2cfe2a787895f7557901e33fa7b356926b54b16e (diff)
downloadgit-09dbb90b09f8f69f79951fed193230a3421dc9d9.zip
git-09dbb90b09f8f69f79951fed193230a3421dc9d9.tar.gz
git-09dbb90b09f8f69f79951fed193230a3421dc9d9.tar.bz2
gc: factor out gc.pruneexpire parsing code
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/gc.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/builtin/gc.c b/builtin/gc.c
index 0e65eff..0728650 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -55,6 +55,17 @@ static void remove_pidfile_on_signal(int signo)
raise(signo);
}
+static void git_config_date_string(const char *key, const char **output)
+{
+ if (git_config_get_string_const(key, output))
+ return;
+ if (strcmp(*output, "now")) {
+ unsigned long now = approxidate("now");
+ if (approxidate(*output) >= now)
+ git_die_config(key, _("Invalid %s: '%s'"), key, *output);
+ }
+}
+
static void gc_config(void)
{
const char *value;
@@ -71,16 +82,7 @@ static void gc_config(void)
git_config_get_int("gc.auto", &gc_auto_threshold);
git_config_get_int("gc.autopacklimit", &gc_auto_pack_limit);
git_config_get_bool("gc.autodetach", &detach_auto);
-
- if (!git_config_get_string_const("gc.pruneexpire", &prune_expire)) {
- if (strcmp(prune_expire, "now")) {
- unsigned long now = approxidate("now");
- if (approxidate(prune_expire) >= now) {
- git_die_config("gc.pruneexpire", _("Invalid gc.pruneexpire: '%s'"),
- prune_expire);
- }
- }
- }
+ git_config_date_string("gc.pruneexpire", &prune_expire);
git_config(git_default_config, NULL);
}