git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/5] grep: stop using PARSE_OPT_NO_INTERNAL_HELP

From
René Scharfe <l.s.r@web.de>
Date
Nov 17, 2015, 10:25 UTC
Message-ID
<564B00B1.1070709@web.de>
In-Reply-To
<564AFF32.1030406@web.de>

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 <l.s.r@web.de>
---
 builtin/grep.c | 17 +----------------
 1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/builtin/grep.c b/builtin/grep.c
index d04f440..749e346 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -612,11 +612,6 @@ static int pattern_callback(const struct option *opt, const char *arg,
 	return 0;
 }
 
-static int help_callback(const struct option *opt, const char *arg, int unset)
-{
-	return -1;
-}
-
 int cmd_grep(int argc, const char **argv, const char *prefix)
 {
 	int hit = 0;
@@ -738,18 +733,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 			PARSE_OPT_OPTARG, NULL, (intptr_t)default_pager },
 		OPT_BOOL(0, "ext-grep", &external_grep_allowed__ignored,
 			 N_("allow calling of grep(1) (ignored by this build)")),
-		{ OPTION_CALLBACK, 0, "help-all", NULL, NULL, N_("show usage"),
-		  PARSE_OPT_HIDDEN | PARSE_OPT_NOARG, help_callback },
 		OPT_END()
 	};
 
-	/*
-	 * 'git grep -h', unlike 'git grep -h <pattern>', is a request
-	 * to show usage information and exit.
-	 */
-	if (argc == 2 && !strcmp(argv[1], "-h"))
-		usage_with_options(grep_usage, options);
-
 	init_grep_defaults();
 	git_config(grep_cmd_config, NULL);
 	grep_init(&opt, prefix);
@@ -766,8 +752,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
 	 */
 	argc = parse_options(argc, argv, prefix, options, grep_usage,
 			     PARSE_OPT_KEEP_DASHDASH |
-			     PARSE_OPT_STOP_AT_NON_OPTION |
-			     PARSE_OPT_NO_INTERNAL_HELP);
+			     PARSE_OPT_STOP_AT_NON_OPTION);
 	grep_commit_pattern_type(pattern_type_arg, &opt);
 
 	if (use_index && !startup_info->have_repository)
-- 
2.6.3
Previous: René ScharfeNext: René Scharfe
Message 5 of 7 in “parse-options: allow -h as a short option”
  1. 0/5 parse-options: allow -h as a short optionRené Scharfe, Nov 17, 2015
  2. 1/5 parse-options: deduplicate parse_options_usage() callsRené Scharfe, Nov 17, 2015
  3. 2/5 parse-options: inline parse_options_usage() at its only remaining callerRené Scharfe, Nov 17, 2015
  4. 3/5 parse-options: allow -h as a short optionRené Scharfe, Nov 17, 2015
  5. 4/5 grep: stop using PARSE_OPT_NO_INTERNAL_HELPRené Scharfe, Nov 17, 2015
  6. 5/5 show-ref: stop using PARSE_OPT_NO_INTERNAL_HELPRené Scharfe, Nov 17, 2015
  7. Junio C HamanoDec 4, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.