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

Re: Git branch outputs usage message on stderr

From
KHKristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>
Date
Jan 15, 2025, 18:33 UTC
Message-ID
<a543c92d-215a-4cc1-a7a3-bcb34c62f33d@app.fastmail.com>
In-Reply-To
<xmqqikqgx74o.fsf@gitster.g>
On Wed, Jan 15, 2025, at 19:29, Junio C Hamano wrote:
Show 22 quoted lines
> From: Junio C Hamano <gitster@pobox.com>
> Date: Wed, 15 Jan 2025 09:56:23 -0800
> Subject: [PATCH] parse-options: add show_usage_help()
>
> Many commands call usage_with_options() when they are asked to give
> the help message, but it incorrectly sends the help text to the
> standard error stream.  When the user asked for it with "git cmd -h",
> the help message is the primary output from the command, hence we
> should send it to the standard output stream.
>
> Introduce a helper function that captures the common pattern
>
> 	if (argc == 2 && !strcmp(argv[1], "-h"))
> 		usage_with_options(usage, options);
>
> and replaces it with
>
> 	show_usage_help(argc, argv, usage, options);
>
> to help correct code paths (there are 40 or so of them).
>
> Suggested-by: Jeff King <peff@peff.net>
+Reported-by: Jonas Konrad <jonas.konrad@uni-muenster.de>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-- 
Kristoffer Haugsbakk
Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 27 in “Git branch outputs usage message on stderr”
  1. Jonas KonradJan 15, 2025
  2. Matěj CeplJan 15, 2025
  3. Jonas KonradJan 15, 2025
  4. Junio C HamanoJan 15, 2025
  5. Kristoffer HaugsbakkJan 15, 2025
  6. Jeff KingJan 15, 2025
  7. Junio C HamanoJan 15, 2025
  8. Junio C HamanoJan 15, 2025
  9. Jeff KingJan 15, 2025
  10. Junio C HamanoJan 15, 2025
  11. Jeff KingJan 15, 2025
  12. Junio C HamanoJan 15, 2025
  13. Jeff KingJan 15, 2025
  14. Junio C HamanoJan 15, 2025
  15. Junio C HamanoJan 16, 2025
  16. Jeff KingJan 16, 2025
  17. Junio C HamanoJan 15, 2025
  18. Jeff KingJan 15, 2025
  19. Junio C HamanoJan 15, 2025
  20. Junio C HamanoJan 15, 2025
  21. Kristoffer HaugsbakkJan 15, 2025
  22. Junio C HamanoJan 15, 2025
  23. Jonas KonradJan 15, 2025
  24. Kristoffer HaugsbakkJan 15, 2025
  25. Junio C HamanoJan 15, 2025
  26. Kristoffer HaugsbakkJan 15, 2025
  27. Junio C HamanoJan 15, 2025

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.