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

[PATCH 3/5] compat/wildmatch: fix case-insensitive matching

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Sep 26, 2012, 11:25 UTC
Message-ID
<1348658741-8146-4-git-send-email-pclouds@gmail.com>
In-Reply-To
<1348658741-8146-1-git-send-email-pclouds@gmail.com>

dowild() does case insensitive matching by lower-casing the text. That means lower case letters in patterns imply case-insensitive matching, but upper case means exact matching.

We do not want that subtlety. Lower case pattern too so iwildmatch() always does what we expect it to do.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 wildmatch.c | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/wildmatch.c b/wildmatch.c
index e824eb2..c7f7f9f 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -81,6 +81,8 @@ static int dowild(const uchar *p, const uchar *text,
 	}
 	if (force_lower_case && ISUPPER(t_ch))
 	    t_ch = tolower(t_ch);
+	if (force_lower_case && ISUPPER(p_ch))
+	    p_ch = tolower(p_ch);
 	switch (p_ch) {
 	  case '\\':
 	    /* Literal match with following character.  Note that the test
-- 
1.7.12.1.406.g6ab07c4
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 5 of 9 in “wildmatch series update”
  1. 0/5 wildmatch series updateNguyễn Thái Ngọc Duy, Sep 26, 2012
  2. 1/5 Import wildmatch from rsyncNguyễn Thái Ngọc Duy, Sep 26, 2012
  3. Ævar Arnfjörð BjarmasonOct 2, 2012
  4. 2/5 compat/wildmatch: remove static variable force_lower_caseNguyễn Thái Ngọc Duy, Sep 26, 2012
  5. 3/5 compat/wildmatch: fix case-insensitive matchingNguyễn Thái Ngọc Duy, Sep 26, 2012
  6. 4/5 Integrate wildmatch to gitNguyễn Thái Ngọc Duy, Sep 26, 2012
  7. 5/5 Support "**" in .gitignore and .gitattributes patterns using wildmatch()Nguyễn Thái Ngọc Duy, Sep 26, 2012
  8. Junio C HamanoSep 27, 2012
  9. Junio C HamanoOct 2, 2012

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.