Skip to content

Commit 05ff821

Browse files
committed
parse-options: clarify PARSE_OPT_NONEG does not reject negative numbers
The name "NONEG" can be misread as "no negative [values]" when it actually means "no [boolean] negation" (the --no-* form). When --inter-hunk-context and -U/--unified were converted from a custom parser to OPT_INTEGER_F with PARSE_OPT_NONEG in d473e2e and 16ed6c9, the implicit rejection of negative values (via isdigit() in the old opt_arg() parser) was silently lost. The previous commits in this series fix the resulting bugs. Add a clarifying note to the flag documentation. Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
1 parent f9cfa0c commit 05ff821

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

parse-options.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ typedef int parse_opt_subcommand_fn(int argc, const char **argv,
116116
* mask of parse_opt_option_flags.
117117
* PARSE_OPT_OPTARG: says that the argument is optional (not for BOOLEANs)
118118
* PARSE_OPT_NOARG: says that this option does not take an argument
119-
* PARSE_OPT_NONEG: says that this option cannot be negated
119+
* PARSE_OPT_NONEG: says that this option cannot be negated (i.e.
120+
* prevents --no-<option> boolean form). Does not reject
121+
* negative numeric values like --option=-1. Use
122+
* OPT_UNSIGNED for options that must be non-negative.
120123
* PARSE_OPT_HIDDEN: this option is skipped in the default usage, and
121124
* shown only in the full usage.
122125
* PARSE_OPT_LASTARG_DEFAULT: says that this option will take the default

0 commit comments

Comments
 (0)