Skip to content

Commit cbb08c2

Browse files
René Scharfegitster
authored andcommitted
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 <[email protected]> Acked-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0f1930c commit cbb08c2

File tree

4 files changed

+5
-13
lines changed

4 files changed

+5
-13
lines changed

builtin/fast-export.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,9 +647,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
647647
"Output full tree for each commit"),
648648
OPT_BOOLEAN(0, "use-done-feature", &use_done_feature,
649649
"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"),
653651
OPT_END()
654652
};
655653

builtin/grep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
777777
struct option options[] = {
778778
OPT_BOOLEAN(0, "cached", &cached,
779779
"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),
782782
OPT_GROUP(""),
783783
OPT_BOOLEAN('v', "invert-match", &opt.invert,
784784
"show non-matching lines"),

parse-options.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
533533
continue;
534534

535535
pos = fprintf(outfile, " ");
536-
if (opts->short_name && !(opts->flags & PARSE_OPT_NEGHELP)) {
536+
if (opts->short_name) {
537537
if (opts->flags & PARSE_OPT_NODASH)
538538
pos += fprintf(outfile, "%c", opts->short_name);
539539
else
@@ -542,9 +542,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx,
542542
if (opts->long_name && opts->short_name)
543543
pos += fprintf(outfile, ", ");
544544
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);
548546
if (opts->type == OPTION_NUMBER)
549547
pos += fprintf(outfile, "-NUM");
550548

parse-options.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ enum parse_opt_option_flags {
4040
PARSE_OPT_LASTARG_DEFAULT = 16,
4141
PARSE_OPT_NODASH = 32,
4242
PARSE_OPT_LITERAL_ARGHELP = 64,
43-
PARSE_OPT_NEGHELP = 128,
4443
PARSE_OPT_SHELL_EVAL = 256
4544
};
4645

@@ -90,9 +89,6 @@ typedef int parse_opt_ll_cb(struct parse_opt_ctx_t *ctx,
9089
* PARSE_OPT_LITERAL_ARGHELP: says that argh shouldn't be enclosed in brackets
9190
* (i.e. '<argh>') in the help message.
9291
* 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.
9692
*
9793
* `callback`::
9894
* pointer to the callback to use for OPTION_CALLBACK or

0 commit comments

Comments
 (0)