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

Re: [PATCH/RFC] setup: update error message to be more meaningful

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jul 25, 2017, 21:21 UTC
Message-ID
<20170725212110.GG13924@aiede.mtv.corp.google.com>
In-Reply-To
<0102015d7ae53b0a-a6505296-9257-4b0d-84d6-2152e17eb070-000000@eu-west-1.amazonses.com>
Hi,
Kaartic Sivaraam wrote:
Show 17 quoted lines
> The error message shown when a flag is found when expecting a
> filename wasn't clear as it didn't communicate what was wrong
> using the 'suitable' words in *all* cases.
>
> Correct case,
>
>         $ git rev-parse commit.c --flags
>         commit.c
>         --flags
>         fatal: bad flag '--flags' used after filename
>
> Incorrect case,
>
>         $ git grep "test" -n
>         fatal: bad flag '-n' used after filename
>
> Change the error message to be general and communicative.

Thanks for writing this. These examples describe *what* the behavior is but don't describe *why* it is wrong or what is expected in its place.

For an initial guess: in the example
	git grep test -n

it is confusing that it says "bad flag used after filename" because test isn't even a filename! At first glance, I would imagine that any of the following behaviors would be nicer:

 1. Treat the command as "git grep -e test -n", or in other words
    "do what I mean" since it is clear enough, at least to humans.
 2. Focus on "argument" instead of "filename" so that the message
    could still apply: something like
	fatal: option '-n' must come before non-option arguments
[...]
Show 8 quoted lines
> --- a/setup.c
> +++ b/setup.c
> @@ -230,7 +230,7 @@ void verify_filename(const char *prefix,
>  		     int diagnose_misspelt_rev)
>  {
>  	if (*arg == '-')
> -		die("bad flag '%s' used after filename", arg);
> +		die("found flag '%s' in place of a filename", arg);

Probably because of the background I am missing described above, it's not clear to me that the new message is any better (or worse) than the existing one. The old message with "after filename" has the virtue of explaining why an option is not expected there.

Thanks and hope that helps, Jonathan

Previous: Kaartic SivaraamNext: Kaartic Sivaraam
Message 3 of 15 in “setup: update error message to be more meaningful”
  1. setup: update error message to be more meaningfulKaartic Sivaraam, Jul 25, 2017
  2. Kaartic SivaraamJul 25, 2017
  3. Jonathan NiederJul 25, 2017
  4. Kaartic SivaraamJul 26, 2017
  5. Junio C HamanoJul 26, 2017
  6. Kaartic SivaraamJul 29, 2017
  7. Junio C HamanoJul 29, 2017
  8. Kaartic SivaraamJul 29, 2017
  9. setup: update error message to be more meaningfulKaartic Sivaraam, Jul 29, 2017
  10. Junio C HamanoJul 29, 2017
  11. Kaartic SivaraamJul 30, 2017
  12. Kaartic SivaraamJul 30, 2017
  13. setup: update error message to be more meaningfulKaartic Sivaraam, Oct 2, 2017
  14. Junio C HamanoOct 3, 2017
  15. Kaartic SivaraamOct 4, 2017

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.