summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichele Ballabio <barra_cuda@katamail.com>2008-03-24 14:02:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-03-27 20:55:15 (GMT)
commit1f4a711a05e00db81da552dd990f6ddff4ffb63e (patch)
treeafa79d66e796ca0ea45409979b6ee915a83e2c97
parent1768905b51601d5d080168059acd24d13b888a2d (diff)
downloadgit-1f4a711a05e00db81da552dd990f6ddff4ffb63e.zip
git-1f4a711a05e00db81da552dd990f6ddff4ffb63e.tar.gz
git-1f4a711a05e00db81da552dd990f6ddff4ffb63e.tar.bz2
parse-options.c: introduce OPT_DATE
There are quite a few places that will need to call approxidate(), when they'll adopt the parse-options system, so this patch adds the function parse_opt_approxidate_cb(), used by OPT_DATE. Signed-off-by: Michele Ballabio <barra_cuda@katamail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--parse-options.c7
-rw-r--r--parse-options.h4
2 files changed, 11 insertions, 0 deletions
diff --git a/parse-options.c b/parse-options.c
index 8e64316..e87cafb 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -409,3 +409,10 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
*(int *)(opt->value) = v;
return 0;
}
+
+int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
+ int unset)
+{
+ *(unsigned long *)(opt->value) = approxidate(arg);
+ return 0;
+}
diff --git a/parse-options.h b/parse-options.h
index 1af62b0..4ee443d 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -94,6 +94,9 @@ struct option {
#define OPT_SET_PTR(s, l, v, h, p) { OPTION_SET_PTR, (s), (l), (v), NULL, (h), 0, NULL, (p) }
#define OPT_INTEGER(s, l, v, h) { OPTION_INTEGER, (s), (l), (v), NULL, (h) }
#define OPT_STRING(s, l, v, a, h) { OPTION_STRING, (s), (l), (v), (a), (h) }
+#define OPT_DATE(s, l, v, h) \
+ { OPTION_CALLBACK, (s), (l), (v), "time",(h), 0, \
+ parse_opt_approxidate_cb }
#define OPT_CALLBACK(s, l, v, a, h, f) \
{ OPTION_CALLBACK, (s), (l), (v), (a), (h), 0, (f) }
@@ -110,6 +113,7 @@ extern NORETURN void usage_with_options(const char * const *usagestr,
/*----- some often used options -----*/
extern int parse_opt_abbrev_cb(const struct option *, const char *, int);
+extern int parse_opt_approxidate_cb(const struct option *, const char *, int);
#define OPT__VERBOSE(var) OPT_BOOLEAN('v', "verbose", (var), "be verbose")
#define OPT__QUIET(var) OPT_BOOLEAN('q', "quiet", (var), "be quiet")