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

Re* [PATCH] fix overslow :/no-such-string-ever-existed diagnostics

From
Junio C Hamano <gitster@pobox.com>
Date
May 10, 2011, 19:05 UTC
Message-ID
<7vvcxiidgi.fsf_-_@alter.siamese.dyndns.org>
In-Reply-To
<7vzkmuidk1.fsf@alter.siamese.dyndns.org>
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);
Previous: Junio C HamanoNext: Matthieu Moy
Message 3 of 5 in “fix overstrict :<path> diagnosis”
  1. fix overstrict :<path> diagnosisJunio C Hamano, May 10, 2011
  2. fix overslow :/no-such-string-ever-existed diagnosticsJunio C Hamano, May 10, 2011
  3. Re* [PATCH] fix overslow :/no-such-string-ever-existed diagnosticsJunio C Hamano, May 10, 2011
  4. Matthieu MoyMay 10, 2011
  5. Junio C HamanoMay 10, 2011

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.