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

[PATCH 1/6] Recognize magic pathspec as filenames

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Oct 11, 2011, 22:44 UTC
Message-ID
<1318373083-13840-2-git-send-email-pclouds@gmail.com>
In-Reply-To
<1318373083-13840-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 .. so that "git log :/" works, not so sure this is correct though
 setup.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/setup.c b/setup.c
index 27c1d47..08f605b 100644
--- a/setup.c
+++ b/setup.c
@@ -58,15 +58,8 @@ static void NORETURN die_verify_filename(const char *prefix, const char *arg)
 	unsigned char sha1[20];
 	unsigned mode;
 
-	/*
-	 * 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);
+	/* 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"
@@ -85,6 +78,11 @@ void verify_filename(const char *prefix, const char *arg)
 {
 	if (*arg == '-')
 		die("bad flag '%s' used after filename", arg);
+
+	/* If it's magic pathspec, just assume it's file name */
+	if (arg[0] == ':' && is_pathspec_magic(arg[1]))
+		return;
+
 	if (check_filename(prefix, arg))
 		return;
 	die_verify_filename(prefix, arg);
-- 
1.7.3.1.256.g2539c.dirty
Previous: Nguyễn Thái Ngọc DuyNext: Junio C Hamano
Message 2 of 12 in “Negation magic pathspec”
  1. 0/6 Negation magic pathspecNguyễn Thái Ngọc Duy, Oct 11, 2011
  2. 1/6 Recognize magic pathspec as filenamesNguyễn Thái Ngọc Duy, Oct 11, 2011
  3. Junio C HamanoOct 12, 2011
  4. Nguyen Thai Ngoc DuyOct 13, 2011
  5. Junio C HamanoOct 13, 2011
  6. 2/6 Replace has_wildcard with PATHSPEC_NOGLOBNguyễn Thái Ngọc Duy, Oct 11, 2011
  7. 3/6 Convert prefix_pathspec() to produce struct pathspec_itemNguyễn Thái Ngọc Duy, Oct 11, 2011
  8. 4/6 Implement parse_pathspec()Nguyễn Thái Ngọc Duy, Oct 11, 2011
  9. 5/6 Convert simple init_pathspec() cases to parse_pathspec()Nguyễn Thái Ngọc Duy, Oct 11, 2011
  10. Junio C HamanoOct 13, 2011
  11. 6/6 Implement negative pathspecNguyễn Thái Ngọc Duy, Oct 11, 2011
  12. Junio C HamanoOct 11, 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.