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>
This commit is contained in:
parent
2cfe2a7878
commit
09dbb90b09
22
builtin/gc.c
22
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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user