diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2009-09-25 20:44:44 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2009-09-29 07:28:47 -0700 |
commit | 6bbfd1fa98b0c1fa1684bd35e64404799f0cc2b3 (patch) | |
tree | 71bb1a417abd88c93872ae14ac4c93741e254152 /test-parse-options.c | |
parent | 5bdc32d3e50d8335c65e136e6b5234c5dd92a7a9 (diff) | |
download | git-6bbfd1fa98b0c1fa1684bd35e64404799f0cc2b3.tar.gz |
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>
Diffstat (limited to 'test-parse-options.c')
-rw-r--r-- | test-parse-options.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test-parse-options.c b/test-parse-options.c index efa734b42e..acd1a2ba70 100644 --- a/test-parse-options.c +++ b/test-parse-options.c @@ -8,6 +8,7 @@ static int abbrev = 7; static int verbose = 0, dry_run = 0, quiet = 0; static char *string = NULL; static char *file = NULL; +static int ambiguous; static int length_callback(const struct option *opt, const char *arg, int unset) { @@ -59,6 +60,10 @@ int main(int argc, const char **argv) number_callback), { OPTION_BOOLEAN, '+', NULL, &boolean, NULL, "same as -b", PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH }, + { OPTION_BOOLEAN, 0, "ambiguous", &ambiguous, NULL, + "positive ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG }, + { OPTION_BOOLEAN, 0, "no-ambiguous", &ambiguous, NULL, + "negative ambiguity", PARSE_OPT_NOARG | PARSE_OPT_NONEG }, OPT_GROUP("Standard options"), OPT__ABBREV(&abbrev), OPT__VERBOSE(&verbose), |