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

Re: [PATCH v1 1/4] refs: avoid "too many arguments"

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 6, 2024, 16:48 UTC
Message-ID
<xmqqed71vbps.fsf@gitster.g>
In-Reply-To
<ZrG_A3UQk56aYJ_m@tanuki>
Patrick Steinhardt <ps@pks.im> writes:
Show 21 quoted lines
>> -	cat >expect <<-EOF &&
>> -	usage: too many arguments
>> -	EOF
>> +	{
>> +		printf "fatal: unknown argument: ${SQ}foo${SQ}\n\n" &&
>> +		( git -C repo refs migrate -h || : )
>> +	} >expect &&
>
> I always have to wonder how helpful it really is to print the usage
> information in such a context. I feel that it is too distracting because
> in many cases, we end up printing dozens of lines of options that drown
> out the single line of information that the user actually cares for,
> namely why the command has failed.
>
> In this case here it is somewhat manageable, because only 4/5th of the
> output are unnecessary noise. But the picture changes as commands grow
> more options over time, making the output less and less usable.
>
> So while I think that it is a big improvement to explicitly point out
> the unknown argument, I think it is step backwards to also print the
> usage info.

Yeah, I somehow was fooled by the original that called a usage() function ;-).

"usage:" should signal that the message given is a command line to show the usage, i.e.

$ git grep -E -e '[^_]usage\("' builtin/\*.c builtin/merge-index.c: usage("git merge-index [-o] [-q] <merge-program> (-a | [--] [<filename>...])"); builtin/unpack-file.c: usage("git unpack-file <blob>");

and is not a signal that the message explains what it found problematic in this particular usage of the command. builtin/refs.c being relatively young do not honor the tradition, it seems.

$ git grep -E -e 'usage\(' builtin/refs.c builtin/refs.c: usage(_("too many arguments")); builtin/refs.c: usage(_("missing --ref-format=<format>"));

I think die(_("...")) would be a lot more appropriate in these two places, including the one I touched.

Thanks.
Previous: Patrick SteinhardtNext: Junio C Hamano
Message 4 of 16 in “make "too many arguments" a bit more useful”
  1. 0/4 make "too many arguments" a bit more usefulJunio C Hamano, Aug 6, 2024
  2. 1/4 refs: avoid "too many arguments"Junio C Hamano, Aug 6, 2024
  3. Patrick SteinhardtAug 6, 2024
  4. Junio C HamanoAug 6, 2024
  5. [RFC] usage_msg_opt() and _optf() must dieJunio C Hamano, Aug 6, 2024
  6. Eric SunshineAug 6, 2024
  7. Junio C HamanoAug 6, 2024
  8. Patrick SteinhardtAug 7, 2024
  9. Justin ToblerAug 6, 2024
  10. Martin ÅgrenAug 6, 2024
  11. refs: avoid "too many arguments"Junio C Hamano, Aug 6, 2024
  12. 2/4 cat-file: avoid "too many arguments"Junio C Hamano, Aug 6, 2024
  13. 3/4 notes: avoid "too many arguments"Junio C Hamano, Aug 6, 2024
  14. 4/4 miscellaneous: avoid "too many arguments"Junio C Hamano, Aug 6, 2024
  15. Eric SunshineAug 6, 2024
  16. Junio C HamanoAug 6, 2024

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.