diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-05-29 14:23:03 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-05-29 14:23:04 -0700 |
commit | 3e1e7624aa2aa39890ca49d0f7bd3af397c22b03 (patch) | |
tree | 013e8e03f854c3458c0c90f7298244ef7efb6e56 /builtin | |
parent | 305e19bdc315f302b935d50abff4a1a405e14b71 (diff) | |
parent | 27ec394a9701675762f02e9af464be2c297c6cf1 (diff) | |
download | git-3e1e7624aa2aa39890ca49d0f7bd3af397c22b03.tar.gz git-3e1e7624aa2aa39890ca49d0f7bd3af397c22b03.tar.xz |
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()
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/prune.c | 4 | ||||
-rw-r--r-- | builtin/reflog.c | 14 |
2 files changed, 9 insertions, 9 deletions
diff --git a/builtin/prune.c b/builtin/prune.c index 85843d4f1..b90e5cc36 100644 --- a/builtin/prune.c +++ b/builtin/prune.c @@ -132,8 +132,8 @@ int cmd_prune(int argc, const char **argv, const char *prefix) OPT__DRY_RUN(&show_only, N_("do not remove, show only")), OPT__VERBOSE(&verbose, N_("report pruned objects")), OPT_BOOL(0, "progress", &show_progress, N_("show progress")), - OPT_DATE(0, "expire", &expire, - N_("expire objects older than <time>")), + OPT_EXPIRY_DATE(0, "expire", &expire, + N_("expire objects older than <time>")), OPT_END() }; char *s; diff --git a/builtin/reflog.c b/builtin/reflog.c index 72a0af70c..54184b3d1 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -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")) |