assert PARSE_OPT_NONEG in parse-options callbacks
In the spirit of 517fe807d6 (assert NOARG/NONEG behavior of
parse-options callbacks, 2018-11-05), let's cover some parse-options
callbacks which expect to be used with PARSE_OPT_NONEG but don't
explicitly assert that this is the case. These callbacks are all used
correctly in the current code, but this will help document their
expectations and future-proof the code.
As a bonus, it also silences -Wunused-parameters (these were added since
the initial sweep of 517fe807d6, and we can't yet turn on
-Wunused-parameters to remind people because it has too many existing
false positives).
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff --git a/builtin/am.c b/builtin/am.c
index 7259186..2c7673f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -2180,6 +2180,8 @@
};
int new_value = SHOW_PATCH_RAW;
+ BUG_ON_OPT_NEG(unset);
+
if (arg) {
for (new_value = 0; new_value < ARRAY_SIZE(valid_modes); new_value++) {
if (!strcmp(arg, valid_modes[new_value]))
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 988445a..78fa08f 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -128,6 +128,8 @@
{
enum commit_graph_split_flags *flags = opt->value;
+ BUG_ON_OPT_NEG(unset);
+
opts.split = 1;
if (!arg)
return 0;
diff --git a/builtin/env--helper.c b/builtin/env--helper.c
index 3aa4282..2734909 100644
--- a/builtin/env--helper.c
+++ b/builtin/env--helper.c
@@ -17,6 +17,8 @@
{
enum cmdmode *cmdmode = opt->value;
+ BUG_ON_OPT_NEG(unset);
+
if (!strcmp(arg, "bool"))
*cmdmode = ENV_HELPER_TYPE_BOOL;
else if (!strcmp(arg, "ulong"))
diff --git a/parse-options-cb.c b/parse-options-cb.c
index d9d3b08..4542d4d 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -105,6 +105,8 @@
struct commit *commit;
struct commit **target = opt->value;
+ BUG_ON_OPT_NEG(unset);
+
if (!arg)
return -1;
if (get_oid(arg, &oid))