Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2022-08-19 11:55:02 +0300
committerJunio C Hamano <gitster@pobox.com>2022-08-21 00:14:55 +0300
commitee610f00e2834dbfbf4b559e6cce866e8f2aecbd (patch)
treec4b1fa4a53ce9e036729c2fbd5e68b0e8d640a19 /builtin/reflog.c
parent21a40847ed4a5ec96b0d9cc87b3fe406e7f8f904 (diff)
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>
Diffstat (limited to 'builtin/reflog.c')
-rw-r--r--builtin/reflog.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 4dd297dce8..8123956847 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -193,6 +193,8 @@ static int expire_unreachable_callback(const struct option *opt,
{
struct cmd_reflog_expire_cb *cmd = opt->value;
+ BUG_ON_OPT_NEG(unset);
+
if (parse_expiry_date(arg, &cmd->expire_unreachable))
die(_("invalid timestamp '%s' given to '--%s'"),
arg, opt->long_name);
@@ -207,6 +209,8 @@ static int expire_total_callback(const struct option *opt,
{
struct cmd_reflog_expire_cb *cmd = opt->value;
+ BUG_ON_OPT_NEG(unset);
+
if (parse_expiry_date(arg, &cmd->expire_total))
die(_("invalid timestamp '%s' given to '--%s'"),
arg, opt->long_name);