Skip to content

Commit 4441549

Browse files
rscharfepeff
authored andcommitted
grep: stop using PARSE_OPT_NO_INTERNAL_HELP
The flag PARSE_OPT_NO_INTERNAL_HELP is set to allow overriding the option -h, except when it's the only one given. This is the default behavior now, so remove the flag and the hand-rolled --help-all handling. The internal --help-all handler now actually shows hidden options, i.e. --debug in this case. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Jeff King <[email protected]>
1 parent 5ad0d3d commit 4441549

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

builtin/grep.c

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,6 @@ static int pattern_callback(const struct option *opt, const char *arg,
612612
return 0;
613613
}
614614

615-
static int help_callback(const struct option *opt, const char *arg, int unset)
616-
{
617-
return -1;
618-
}
619-
620615
int cmd_grep(int argc, const char **argv, const char *prefix)
621616
{
622617
int hit = 0;
@@ -738,18 +733,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
738733
PARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },
739734
OPT_BOOL(0, "ext-grep", &external_grep_allowed__ignored,
740735
N_("allow calling of grep(1) (ignored by this build)")),
741-
{ OPTION_CALLBACK, 0, "help-all", NULL, NULL, N_("show usage"),
742-
PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, help_callback },
743736
OPT_END()
744737
};
745738

746-
/*
747-
* 'git grep -h', unlike 'git grep -h <pattern>', is a request
748-
* to show usage information and exit.
749-
*/
750-
if (argc == 2 && !strcmp(argv[1], "-h"))
751-
usage_with_options(grep_usage, options);
752-
753739
init_grep_defaults();
754740
git_config(grep_cmd_config, NULL);
755741
grep_init(&opt, prefix);
@@ -766,8 +752,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
766752
*/
767753
argc = parse_options(argc, argv, prefix, options, grep_usage,
768754
PARSE_OPT_KEEP_DASHDASH |
769-
PARSE_OPT_STOP_AT_NON_OPTION |
770-
PARSE_OPT_NO_INTERNAL_HELP);
755+
PARSE_OPT_STOP_AT_NON_OPTION);
771756
grep_commit_pattern_type(pattern_type_arg, &opt);
772757

773758
if (use_index && !startup_info->have_repository)

0 commit comments

Comments
 (0)