summaryrefslogtreecommitdiff
path: root/date.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-05-29 21:23:03 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-05-29 21:23:04 (GMT)
commit3e1e7624aa2aa39890ca49d0f7bd3af397c22b03 (patch)
tree013e8e03f854c3458c0c90f7298244ef7efb6e56 /date.c
parent305e19bdc315f302b935d50abff4a1a405e14b71 (diff)
parent27ec394a9701675762f02e9af464be2c297c6cf1 (diff)
downloadgit-3e1e7624aa2aa39890ca49d0f7bd3af397c22b03.zip
git-3e1e7624aa2aa39890ca49d0f7bd3af397c22b03.tar.gz
git-3e1e7624aa2aa39890ca49d0f7bd3af397c22b03.tar.bz2
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 'date.c')
-rw-r--r--date.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/date.c b/date.c
index df20d0b..29f1540 100644
--- a/date.c
+++ b/date.c
@@ -711,6 +711,28 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
return 0; /* success */
}
+int parse_expiry_date(const char *date, unsigned long *timestamp)
+{
+ int errors = 0;
+
+ if (!strcmp(date, "never") || !strcmp(date, "false"))
+ *timestamp = 0;
+ else if (!strcmp(date, "all") || !strcmp(date, "now"))
+ /*
+ * We take over "now" here, which usually translates
+ * to the current timestamp. This is because the user
+ * really means to expire everything she has done in
+ * the past, and by definition reflogs are the record
+ * of the past, and there is nothing from the future
+ * to be kept.
+ */
+ *timestamp = ULONG_MAX;
+ else
+ *timestamp = approxidate_careful(date, &errors);
+
+ return errors;
+}
+
int parse_date(const char *date, char *result, int maxlen)
{
unsigned long timestamp;