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

[PATCH/RFC] parse-options: allow to define hidden synonym options

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 19, 2007, 06:09 UTC
Message-ID
<7v4pfircka.fsf@gitster.siamese.dyndns.org>

By setting the help member to NULL, you can implement an option that is not shown in the "git-cmd -h" help output. This is useful to support backward compatible synonyms without cluttering the help text.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 parse-options.c |    2 ++
 parse-options.h |    2 +-
 2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/parse-options.c b/parse-options.c
index d3e608a..1ee2c81 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -284,6 +284,8 @@ void usage_with_options(const char * const *usagestr,
 			if (*opts->help)
 				fprintf(stderr, "%s\n", opts->help);
 			continue;
+		} else if (!opts->help) {
+			continue;
 		}
 
 		pos = fprintf(stderr, "    ");
diff --git a/parse-options.h b/parse-options.h
index a8760ac..de249a0 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -49,7 +49,7 @@ typedef int parse_opt_cb(const struct option *, const char *arg, int unset);
  *
  * `help`::
  *   the short help associated to what the option does.
- *   Must never be NULL (except for OPTION_END).
+ *   option with this field set to NULL does not appear in the help listing.
  *   OPTION_GROUP uses this pointer to store the group header.
  *
  * `flags`::
-- 
1.5.3.6.1779.ga3ed
Next: Junio C Hamano
Message 1 of 3 in “parse-options: allow to define hidden synonym options”
  1. parse-options: allow to define hidden synonym optionsJunio C Hamano, Nov 19, 2007
  2. branch --contains=<commit>Junio C Hamano, Nov 19, 2007
  3. Pierre HabouzitNov 19, 2007

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.