parse-opt: ignore negation of OPT_NONEG for ambiguity checks
parse_long_opt always matches both --opt and --no-opt for any option "opt", and only get_value checks whether --no-opt is actually valid. Since the options for git branch contains both "no-merged" and "merged" there are two matches for --no-merge, but no exact match. With this patch the negation of a NONEG option is rejected earlier, but it changes the error message from "option `no-opt' isn't available" to "unknown option `no-opt'". [jk: added test] Signed-off-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:

committed by
Shawn O. Pearce

parent
5bdc32d3e5
commit
6bbfd1fa98
@ -33,6 +33,8 @@ Magic arguments
|
||||
--quux means --quux
|
||||
-NUM set integer to NUM
|
||||
+ same as -b
|
||||
--ambiguous positive ambiguity
|
||||
--no-ambiguous negative ambiguity
|
||||
|
||||
Standard options
|
||||
--abbrev[=<n>] use <n> digits to display SHA-1s
|
||||
@ -315,4 +317,22 @@ test_expect_success 'OPT_NUMBER_CALLBACK() works' '
|
||||
test_cmp expect output
|
||||
'
|
||||
|
||||
cat >expect <<EOF
|
||||
boolean: 0
|
||||
integer: 0
|
||||
timestamp: 0
|
||||
string: (not set)
|
||||
abbrev: 7
|
||||
verbose: 0
|
||||
quiet: no
|
||||
dry run: no
|
||||
file: (not set)
|
||||
EOF
|
||||
|
||||
test_expect_success 'negation of OPT_NONEG flags is not ambiguous' '
|
||||
test-parse-options --no-ambig >output 2>output.err &&
|
||||
test ! -s output.err &&
|
||||
test_cmp expect output
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user