Skip to content

Commit ee610f0

Browse files
peffgitster
authored andcommitted
reflog: assert PARSE_OPT_NONEG in parse-options callbacks
In the spirit of 517fe80 (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 21a4084 commit ee610f0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

builtin/reflog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ static int expire_unreachable_callback(const struct option *opt,
193193
{
194194
struct cmd_reflog_expire_cb *cmd = opt->value;
195195

196+
BUG_ON_OPT_NEG(unset);
197+
196198
if (parse_expiry_date(arg, &cmd->expire_unreachable))
197199
die(_("invalid timestamp '%s' given to '--%s'"),
198200
arg, opt->long_name);
@@ -207,6 +209,8 @@ static int expire_total_callback(const struct option *opt,
207209
{
208210
struct cmd_reflog_expire_cb *cmd = opt->value;
209211

212+
BUG_ON_OPT_NEG(unset);
213+
210214
if (parse_expiry_date(arg, &cmd->expire_total))
211215
die(_("invalid timestamp '%s' given to '--%s'"),
212216
arg, opt->long_name);

0 commit comments

Comments
 (0)