Merge branch 'jc/prune-all'
We used the approxidate() parser for "--expire=<timestamp>" options of various commands, but it is better to treat --expire=all and --expire=now a bit more specially than using the current timestamp. Update "git gc" and "git reflog" with a new parsing function for expiry dates. * jc/prune-all: prune: introduce OPT_EXPIRY_DATE() and use it api-parse-options.txt: document "no-" for non-boolean options git-gc.txt, git-reflog.txt: document new expiry options date.c: add parse_expiry_date()
This commit is contained in:
@ -496,11 +496,9 @@ static int parse_expire_cfg_value(const char *var, const char *value, unsigned l
|
||||
{
|
||||
if (!value)
|
||||
return config_error_nonbool(var);
|
||||
if (!strcmp(value, "never") || !strcmp(value, "false")) {
|
||||
*expire = 0;
|
||||
return 0;
|
||||
}
|
||||
*expire = approxidate(value);
|
||||
if (parse_expiry_date(value, expire))
|
||||
return error(_("%s' for '%s' is not a valid timestamp"),
|
||||
value, var);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -614,11 +612,13 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
||||
if (!strcmp(arg, "--dry-run") || !strcmp(arg, "-n"))
|
||||
cb.dry_run = 1;
|
||||
else if (!prefixcmp(arg, "--expire=")) {
|
||||
cb.expire_total = approxidate(arg + 9);
|
||||
if (parse_expiry_date(arg + 9, &cb.expire_total))
|
||||
die(_("'%s' is not a valid timestamp"), arg);
|
||||
explicit_expiry |= EXPIRE_TOTAL;
|
||||
}
|
||||
else if (!prefixcmp(arg, "--expire-unreachable=")) {
|
||||
cb.expire_unreachable = approxidate(arg + 21);
|
||||
if (parse_expiry_date(arg + 21, &cb.expire_unreachable))
|
||||
die(_("'%s' is not a valid timestamp"), arg);
|
||||
explicit_expiry |= EXPIRE_UNREACH;
|
||||
}
|
||||
else if (!strcmp(arg, "--stale-fix"))
|
||||
|
Reference in New Issue
Block a user