[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-fileCorrect case,
$ git rev-parse README.md --flags
README.md
--flags
fatal: bad flag '--flags' used after filenameIncorrect case,
$ git grep "some random regex" -n
fatal: bad flag '-n' used after filenameThe 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 argumentsSigned-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