parse-options: remove PARSE_OPT_NEGHELP

PARSE_OPT_NEGHELP is confusing because short options defined with that flag do the opposite of what the helptext says. It is also not needed anymore now that options starting with no- can be negated by removing that prefix. Convert its only two users to OPT_NEGBIT() and OPT_BOOL() and then remove support for PARSE_OPT_NEGHELP. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Feb 28, 2012 at 20:06 UTC cbb08c2e0b41ab162838aa1e83b959bac91151e2
4 files changed +5 -13
builtin/fast-export.c
+1 -3
@@ -647,9 +647,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
647 "Output full tree for each commit"),
648 OPT_BOOLEAN(0, "use-done-feature", &use_done_feature,
649 "Use the done feature to terminate the stream"),
650 - { OPTION_NEGBIT, 0, "data", &no_data, NULL,
651 - "Skip output of blob data",
652 - PARSE_OPT_NOARG | PARSE_OPT_NEGHELP, NULL, 1 },
650 + OPT_BOOL(0, "no-data", &no_data, "Skip output of blob data"),
651 OPT_END()
652 };
653
builtin/grep.c
+2 -2
@@ -777,8 +777,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
777 struct option options[] = {
778 OPT_BOOLEAN(0, "cached", &cached,
779 "search in index instead of in the work tree"),
780 - OPT_BOOLEAN(0, "index", &use_index,
781 - "--no-index finds in contents not managed by git"),
780 + OPT_NEGBIT(0, "no-index", &use_index,
781 + "finds in contents not managed by git", 1),
782 OPT_GROUP(""),
783 OPT_BOOLEAN('v', "invert-match", &opt.invert,
784 "show non-matching lines"),
parse-options.c
+2 -4
@@ -533,7 +533,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
533 continue;
534
535 pos = fprintf(outfile, " ");
536 - if (opts->short_name && !(opts->flags & PARSE_OPT_NEGHELP)) {
536 + if (opts->short_name) {
537 if (opts->flags & PARSE_OPT_NODASH)
538 pos += fprintf(outfile, "%c", opts->short_name);
539 else
@@ -542,9 +542,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
542 if (opts->long_name && opts->short_name)
543 pos += fprintf(outfile, ", ");
544 if (opts->long_name)
545 - pos += fprintf(outfile, "--%s%s",
546 - (opts->flags & PARSE_OPT_NEGHELP) ? "no-" : "",
547 - opts->long_name);
545 + pos += fprintf(outfile, "--%s", opts->long_name);
546 if (opts->type == OPTION_NUMBER)
547 pos += fprintf(outfile, "-NUM");
548
parse-options.h
-4
@@ -40,7 +40,6 @@ enum parse_opt_option_flags {
40 PARSE_OPT_LASTARG_DEFAULT = 16,
41 PARSE_OPT_NODASH = 32,
42 PARSE_OPT_LITERAL_ARGHELP = 64,
43 - PARSE_OPT_NEGHELP = 128,
43 PARSE_OPT_SHELL_EVAL = 256
44 };
45
@@ -90,9 +89,6 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
89 * PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets
90 * (i.e. '<argh>') in the help message.
91 * Useful for options with multiple parameters.
93 - * PARSE_OPT_NEGHELP: says that the long option should always be shown with
94 - * the --no prefix in the usage message. Sometimes
95 - * useful for users of OPTION_NEGBIT.
92 *
93 * `callback`::
94 * pointer to the callback to use for OPTION_CALLBACK or