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

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

From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Jul 29, 2017, 12:41 UTC
Message-ID
<0102015d8e5dd2c8-be70b5d5-8a65-4366-8cac-84a0f31ba744-000000@eu-west-1.amazonses.com>
In-Reply-To
<1501330390.2001.1.camel@gmail.com>

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.

        $ git ls-files
        README.md
        test-file
Correct case,
        $ git rev-parse README.md --flags
        README.md
        --flags
        fatal: bad flag '--flags' used after filename
Incorrect case,
        $ git grep "some random regex" -n
        fatal: bad flag '-n' used after filename

The above case is incorrect as "some random regex" isn't a filename in this case.

Change the error message to be general and communicative. This results in the following output,

        $ git rev-parse README.md --flags
        README.md
        --flags
        fatal: option '--flags' must come before non-option arguments
        $ git grep "some random regex" -n
        fatal: option '-n' must come before non-option arguments
Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
---
 setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/setup.c b/setup.c
index 860507e1fdb2d..09c79328247dd 100644
--- 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("option '%s' must come before non-option arguments", arg);
 	if (looks_like_pathspec(arg) || check_filename(prefix, arg))
 		return;
 	die_verify_filename(prefix, arg, diagnose_misspelt_rev);

--
https://github.com/git/git/pull/393
Previous: Kaartic SivaraamNext: Junio C Hamano
Message 9 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.