From: John Cai <johncai86@xxxxxxxxx> Extract the logic in parse_opt_expiry_date_cb into a helper parse_opt_expiry_date. This is to prepare for the following commit where we need to parse an expiry date that gets passed into a callback function in opt->value as part of a struct. The next commit will utilize this helper in a callback function that aims to wrap the functionality in parse_opt_expiry_date_cb. Signed-off-by: "John Cai" <johncai86@xxxxxxxxx> --- parse-options-cb.c | 7 ++++++- parse-options.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/parse-options-cb.c b/parse-options-cb.c index 3c811e1e4a7..3edb88a54d8 100644 --- a/parse-options-cb.c +++ b/parse-options-cb.c @@ -34,10 +34,15 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset) int parse_opt_expiry_date_cb(const struct option *opt, const char *arg, int unset) +{ + return parse_opt_expiry_date((timestamp_t *)opt->value, arg, unset); +} + +int parse_opt_expiry_date(timestamp_t *t, const char *arg, int unset) { if (unset) arg = "never"; - if (parse_expiry_date(arg, (timestamp_t *)opt->value)) + if (parse_expiry_date(arg, t)) die(_("malformed expiration date '%s'"), arg); return 0; } diff --git a/parse-options.h b/parse-options.h index 275fb440818..0a15bac8619 100644 --- a/parse-options.h +++ b/parse-options.h @@ -301,6 +301,7 @@ enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx, const char *, int); int parse_opt_passthru(const struct option *, const char *, int); int parse_opt_passthru_argv(const struct option *, const char *, int); +int parse_opt_expiry_date(timestamp_t *, const char *, int); #define OPT__VERBOSE(var, h) OPT_COUNTUP('v', "verbose", (var), (h)) #define OPT__QUIET(var, h) OPT_COUNTUP('q', "quiet", (var), (h)) -- gitgitgadget