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

[PATCH/WIP 08/10] common_prefix/read_directory: treat PATHSPEC_ICASE like wildcards

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 13, 2013, 12:49 UTC
Message-ID
<1358081379-17752-9-git-send-email-pclouds@gmail.com>
In-Reply-To
<1358081379-17752-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 dir.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/dir.c b/dir.c
index 760b776..d0e7ca8 100644
--- a/dir.c
+++ b/dir.c
@@ -66,15 +66,22 @@ static size_t common_prefix_len(const struct pathspec *pathspec)
 	int n;
 	size_t max = 0;
 
+	/*
+	 * ":(icase)path" is treated as a pathspec full of wildcard
+	 */
 	GUARD_PATHSPEC(pathspec,
 		       PATHSPEC_FROMTOP |
 		       PATHSPEC_LITERAL |
-		       PATHSPEC_GLOB);
+		       PATHSPEC_GLOB |
+		       PATHSPEC_ICASE);
 
 	for (n = 0; n < pathspec->nr; n++) {
-		size_t i = 0, len = 0;
-		while (i < pathspec->items[n].nowildcard_len &&
-		       (n == 0 || i < max)) {
+		size_t i = 0, len = 0, item_len;
+		if (pathspec->items[n].magic & PATHSPEC_ICASE)
+			item_len = pathspec->items[n].prefix;
+		else
+			item_len = pathspec->items[n].nowildcard_len;
+		while (i < item_len && (n == 0 || i < max)) {
 			char c = pathspec->items[n].match[i];
 			if (c != pathspec->items[0].match[i])
 				break;
@@ -1240,7 +1247,8 @@ int read_directory(struct dir_struct *dir, const char *path, int len, const stru
 		GUARD_PATHSPEC(pathspec,
 			       PATHSPEC_FROMTOP |
 			       PATHSPEC_LITERAL |
-			       PATHSPEC_GLOB);
+			       PATHSPEC_GLOB |
+			       PATHSPEC_ICASE);
 
 	if (has_symlink_leading_path(path, len))
 		return dir->nr;
-- 
1.8.0.rc2.23.g1fb49df
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 9 of 11 in “Fancy pathspec stuff”
  1. 00/10 Fancy pathspec stuffNguyễn Thái Ngọc Duy, Jan 13, 2013
  2. 01/10 pathspec: allow to use alternate char for quoting long magic mnemonicNguyễn Thái Ngọc Duy, Jan 13, 2013
  3. 02/10 parse_pathspec: make sure the prefix part is wildcard-freeNguyễn Thái Ngọc Duy, Jan 13, 2013
  4. 03/10 pathspec: support :(literal) syntax for noglob pathspecNguyễn Thái Ngọc Duy, Jan 13, 2013
  5. 04/10 parse_pathspec: save prefix informationNguyễn Thái Ngọc Duy, Jan 13, 2013
  6. 05/10 pathspec: prepare for :(glob)path syntaxNguyễn Thái Ngọc Duy, Jan 13, 2013
  7. 06/10 Enable :(glob)path syntax for a lot of commandsNguyễn Thái Ngọc Duy, Jan 13, 2013
  8. 07/10 parse_pathspec: accept :(icase)path syntaxNguyễn Thái Ngọc Duy, Jan 13, 2013
  9. 08/10 common_prefix/read_directory: treat PATHSPEC_ICASE like wildcardsNguyễn Thái Ngọc Duy, Jan 13, 2013
  10. 09/10 pathspec: support icase in match_pathspec_depth and tree_entry_interestingNguyễn Thái Ngọc Duy, Jan 13, 2013
  11. 10/10 Enable ls-files and ls-tree for testing PATHSPEC_ICASENguyễn Thái Ngọc Duy, Jan 13, 2013

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.