git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kaartic Sivaraam <kaartic.sivaraam@gmail.com>
To: git@vger.kernel.org
Cc: Jonathan Nieder <jrnieder@gmail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Subject: [PATCH v2] setup: update error message to be more meaningful
Date: Mon,  2 Oct 2017 23:00:02 +0530	[thread overview]
Message-ID: <20171002173002.4278-1-kaarticsivaraam@gmail.com> (raw)
In-Reply-To: <xmqqlgnbq7sc.fsf@gitster.mtv.corp.google.com>

From: Kaartic Sivaraam <kaarticsivaraam91196@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>
---
 Changes in v2:

    Change in error message.

 setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/setup.c b/setup.c
index 860507e1f..09c793282 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);
-- 
2.14.1.935.ge2b2bcd8a


  parent reply	other threads:[~2017-10-02 17:30 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-25 17:57 [PATCH/RFC] setup: update error message to be more meaningful Kaartic Sivaraam
2017-07-25 18:16 ` Kaartic Sivaraam
2017-07-25 21:21 ` Jonathan Nieder
2017-07-26 13:08   ` Kaartic Sivaraam
2017-07-26 20:09   ` Junio C Hamano
2017-07-29  2:44     ` Kaartic Sivaraam
2017-07-29  3:53       ` Junio C Hamano
2017-07-29 12:13         ` Kaartic Sivaraam
2017-07-29 12:41           ` [PATCH] " Kaartic Sivaraam
2017-07-29 16:10           ` [PATCH/RFC] " Junio C Hamano
2017-07-30 10:47             ` Kaartic Sivaraam
2017-07-30 11:03               ` Kaartic Sivaraam
2017-10-02 17:30     ` Kaartic Sivaraam [this message]
2017-10-03  0:32       ` [PATCH v2] " Junio C Hamano
2017-10-04 14:18         ` Kaartic Sivaraam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171002173002.4278-1-kaarticsivaraam@gmail.com \
    --to=kaartic.sivaraam@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    --cc=kaarticsivaraam91196@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).