git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: Re* [PATCH] fix overslow :/no-such-string-ever-existed diagnostics
Date: Tue, 10 May 2011 12:05:01 -0700	[thread overview]
Message-ID: <7vvcxiidgi.fsf_-_@alter.siamese.dyndns.org> (raw)
In-Reply-To: <7vzkmuidk1.fsf@alter.siamese.dyndns.org> (Junio C. Hamano's message of "Tue, 10 May 2011 12:02:54 -0700")

Junio C Hamano <gitster@pobox.com> writes:

>    We may want to add a guard at the beginning of die_verify_filename() to
>    omit the extra call to get_sha1_with_mode_1(only_to_die=1) when arg
>    looks like a magic pathspec, i.e. ":" followed by anything !isalnum().

... which would look like this.

diff --git a/setup.c b/setup.c
index 50e8548..fd4ce59 100644
--- a/setup.c
+++ b/setup.c
@@ -85,8 +85,17 @@ static void NORETURN die_verify_filename(const char *prefix, const char *arg)
 {
 	unsigned char sha1[20];
 	unsigned mode;
-	/* try a detailed diagnostic ... */
-	get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);
+
+	/*
+	 * Saying "'(icase)foo' does not exist in the index" when the
+	 * user gave us ":(icase)foo" is just stupid.  A magic pathspec
+	 * begins with a colon and is followed by a non-alnum; do not
+	 * let get_sha1_with_mode_1(only_to_die=1) to even trigger.
+	 */
+	if (!(arg[0] == ':' && !isalnum(arg[1])))
+		/* try a detailed diagnostic ... */
+		get_sha1_with_mode_1(arg, sha1, &mode, 1, prefix);
+
 	/* ... or fall back the most general message. */
 	die("ambiguous argument '%s': unknown revision or path not in the working tree.\n"
 	    "Use '--' to separate paths from revisions", arg);

  reply	other threads:[~2011-05-10 19:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-10 18:10 [PATCH] fix overstrict :<path> diagnosis Junio C Hamano
2011-05-10 19:02 ` [PATCH] fix overslow :/no-such-string-ever-existed diagnostics Junio C Hamano
2011-05-10 19:05   ` Junio C Hamano [this message]
2011-05-10 20:41   ` Matthieu Moy
2011-05-10 23:11     ` Junio C Hamano

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=7vvcxiidgi.fsf_-_@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Matthieu.Moy@imag.fr \
    --cc=git@vger.kernel.org \
    /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).