reflog: assert PARSE_OPT_NONEG in parse-options callbacks

In the spirit of 517fe807d6 (assert NOARG/NONEG behavior of parse-options callbacks, 2018-11-05), this asserts that our callbacks were invoked using the right flags (since otherwise they'd segfault on the NULL arg). Both cases are already correct here, so this is mostly about annotating the functions, and appeasing -Wunused-parameters. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 19, 2022 at 04:55 UTC ee610f00e2834dbfbf4b559e6cce866e8f2aecbd
1 file changed +4
builtin/reflog.c
+4
@@ -193,6 +193,8 @@ static int expire_unreachable_callback(const struct option *opt,
193 {
194 struct cmd_reflog_expire_cb *cmd = opt->value;
195
196 + BUG_ON_OPT_NEG(unset);
197 +
198 if (parse_expiry_date(arg, &cmd->expire_unreachable))
199 die(_("invalid timestamp '%s' given to '--%s'"),
200 arg, opt->long_name);
@@ -207,6 +209,8 @@ static int expire_total_callback(const struct option *opt,
209 {
210 struct cmd_reflog_expire_cb *cmd = opt->value;
211
212 + BUG_ON_OPT_NEG(unset);
213 +
214 if (parse_expiry_date(arg, &cmd->expire_total))
215 die(_("invalid timestamp '%s' given to '--%s'"),
216 arg, opt->long_name);