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

[PATCH 1/2] bugreport: avoid duplicating options in usage()

From
Carlo Marcelo Arenas Belón <carenas@gmail.com>
Date
Sep 4, 2021, 02:12 UTC
Message-ID
<20210904021231.88534-2-carenas@gmail.com>
In-Reply-To
<20210904021231.88534-1-carenas@gmail.com>

238b439d69 (bugreport: add tool to generate debugging info, 2020-04-16) includes the options with the commandline, which then means they will be duplicated in the output of `git bugreport -h`.

remove them and while at it, make sure usage() is called if the wrong number of parameters is provided (ex: `git bugreport help`)

Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com>
---
 builtin/bugreport.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 9915a5841d..17042381c3 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -5,7 +5,6 @@
 #include "compat/compiler.h"
 #include "run-command.h"
 
-
 static void get_system_info(struct strbuf *sys_info)
 {
 	struct utsname uname_info;
@@ -87,7 +86,7 @@ static void get_populated_hooks(struct strbuf *hook_info, int nongit)
 }
 
 static const char * const bugreport_usage[] = {
-	N_("git bugreport [-o|--output-directory <file>] [-s|--suffix <format>]"),
+	N_("git bugreport"),
 	NULL
 };
 
@@ -141,6 +140,8 @@ int cmd_bugreport(int argc, const char **argv, const char *prefix)
 
 	argc = parse_options(argc, argv, prefix, bugreport_options,
 			     bugreport_usage, 0);
+	if (argc)
+		usage_with_options(bugreport_usage, bugreport_options);
 
 	/* Prepare the path to put the result */
 	prefixed_filename = prefix_filename(prefix,
-- 
2.33.0.481.g26d3bed244
Previous: Carlo Marcelo Arenas BelónNext: Junio C Hamano
Message 3 of 8 in “Documentation: fix default directory of git bugreport -o”
  1. Documentation: fix default directory of git bugreport -oBagas Sanjaya, Sep 3, 2021
  2. bugreport papercutsCarlo Marcelo Arenas Belón, Sep 4, 2021
  3. 1/2 bugreport: avoid duplicating options in usage()Carlo Marcelo Arenas Belón, Sep 4, 2021
  4. Junio C HamanoSep 7, 2021
  5. 2/2 bugreport: slightly better memory managementCarlo Marcelo Arenas Belón, Sep 4, 2021
  6. Junio C HamanoSep 7, 2021
  7. Bagas SanjayaSep 4, 2021
  8. Junio C HamanoSep 7, 2021

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.