assert PARSE_OPT_NONEG in parse-options callbacks
In the spirit of517fe807d6
(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 of517fe807d6
, 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>
This commit is contained in:
parent
424e28fcad
commit
8d2aa8dfac
@ -2180,6 +2180,8 @@ static int parse_opt_show_current_patch(const struct option *opt, const char *ar
|
|||||||
};
|
};
|
||||||
int new_value = SHOW_PATCH_RAW;
|
int new_value = SHOW_PATCH_RAW;
|
||||||
|
|
||||||
|
BUG_ON_OPT_NEG(unset);
|
||||||
|
|
||||||
if (arg) {
|
if (arg) {
|
||||||
for (new_value = 0; new_value < ARRAY_SIZE(valid_modes); new_value++) {
|
for (new_value = 0; new_value < ARRAY_SIZE(valid_modes); new_value++) {
|
||||||
if (!strcmp(arg, valid_modes[new_value]))
|
if (!strcmp(arg, valid_modes[new_value]))
|
||||||
|
@ -128,6 +128,8 @@ static int write_option_parse_split(const struct option *opt, const char *arg,
|
|||||||
{
|
{
|
||||||
enum commit_graph_split_flags *flags = opt->value;
|
enum commit_graph_split_flags *flags = opt->value;
|
||||||
|
|
||||||
|
BUG_ON_OPT_NEG(unset);
|
||||||
|
|
||||||
opts.split = 1;
|
opts.split = 1;
|
||||||
if (!arg)
|
if (!arg)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -17,6 +17,8 @@ static int option_parse_type(const struct option *opt, const char *arg,
|
|||||||
{
|
{
|
||||||
enum cmdmode *cmdmode = opt->value;
|
enum cmdmode *cmdmode = opt->value;
|
||||||
|
|
||||||
|
BUG_ON_OPT_NEG(unset);
|
||||||
|
|
||||||
if (!strcmp(arg, "bool"))
|
if (!strcmp(arg, "bool"))
|
||||||
*cmdmode = ENV_HELPER_TYPE_BOOL;
|
*cmdmode = ENV_HELPER_TYPE_BOOL;
|
||||||
else if (!strcmp(arg, "ulong"))
|
else if (!strcmp(arg, "ulong"))
|
||||||
|
@ -105,6 +105,8 @@ int parse_opt_commit(const struct option *opt, const char *arg, int unset)
|
|||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
struct commit **target = opt->value;
|
struct commit **target = opt->value;
|
||||||
|
|
||||||
|
BUG_ON_OPT_NEG(unset);
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
return -1;
|
return -1;
|
||||||
if (get_oid(arg, &oid))
|
if (get_oid(arg, &oid))
|
||||||
|
Loading…
Reference in New Issue
Block a user