Skip to contentSkip to conversation

Add case insensitive support in matching pathspec

PATCH In review Nguyễn Thái Ngọc Duy 3 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add case insensitive support in matching pathspec

Commit 21444f1 (Add case insensitivity support when using git ls-files
- 2010-10-03) teaches match_pathspec() to ignore case when core.ignorecase=true.

match_pathspec_depth() is developed independently and does not have this feature. Teach it.

---
On top of nd/struct-pathspec, but requires jj/icase-directory. I can rebase the series on top of master if it causes too many conflicts.

 dir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
dir.c +2 -2
index b1407a5..2597f81 100644
@@ -192,7 +192,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
 	if (!*match)
 		return MATCHED_RECURSIVELY;
 
-	if (matchlen <= namelen && !strncmp(match, name, matchlen)) {
+	if (matchlen <= namelen && !strncmp_icase(match, name, matchlen)) {
 		if (matchlen == namelen)
 			return MATCHED_EXACTLY;
 
@@ -200,7 +200,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
 			return MATCHED_RECURSIVELY;
 	}
 
-	if (item->has_wildcard && !fnmatch(match, name, 0))
+	if (item->has_wildcard && !fnmatch_icase(match, name, 0))
 		return MATCHED_FNMATCH;
 
 	return 0;
Signature · 1 line
1.7.2.2
#1 lore raw
Quoted 6 lines · Nguyễn Thái Ngọc Duy

Commit 21444f1 (Add case insensitivity support when using git ls-files
- 2010-10-03) teaches match_pathspec() to ignore case when core.ignorecase=true.

match_pathspec_depth() is developed independently and does not have this feature. Teach it.

Is match_pathspec_depth() used to match names of files on the filesystem, or names of files in the index or in the repository?

core.ignorecase should be honored only when files on the filesystem are matched, IMO.

-- Hannes

#2 lore raw

2011/2/4 Johannes Sixt <[email protected]>:

Quoted 5 lines · Nguyễn Thái Ngọc Duy
Quoted 4 lines

Commit 21444f1 (Add case insensitivity support when using git ls-files
- 2010-10-03) teaches match_pathspec() to ignore case when core.ignorecase=true.

Quoted 8 lines
Quoted 2 lines

match_pathspec_depth() is developed independently and does not have this feature. Teach it.

Is match_pathspec_depth() used to match names of files on the filesystem, or names of files in the index or in the repository?

core.ignorecase should be honored only when files on the filesystem are matched, IMO.

Names in index, just as same as match_pathspec().

Signature · 1 line
Duy
#3 lore raw
Quoted 4 lines · Nguyen Thai Ngoc Duy
Quoted 2 lines

core.ignorecase should be honored only when files on the filesystem are matched, IMO.

Names in index, just as same as match_pathspec().

If the matched entities are names in the index, they should already be canonical and we shouldn't be matching with icase, no?

#4 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 4 lines · Nguyen Thai Ngoc Duy
Quoted 2 lines

core.ignorecase should be honored only when files on the filesystem are matched, IMO.

Names in index, just as same as match_pathspec().

If the matched entities are names in the index, they should already be canonical and we shouldn't be matching with icase, no?

The patterns are case-insensitive. The example given in 21444f is "git ls-files mydir" should also match MyDir/* in index. Although by modifying match_one(), it affects more than just git-ls-files. I'm not the original author, so Joshua, was that patch to fix git-ls-files only?

Signature · 1 line
Duy
#5 lore raw
In reply to Nguyễn Thái Ngọc Duy
Quoted 2 lines · Nguyễn Thái Ngọc Duy

On top of nd/struct-pathspec, but requires jj/icase-directory. I can rebase the series on top of master if it causes too many conflicts.

I am in the middle of rewinding 'next' and have already rebased the topic; I will queue the result in 'pu' so could you check the result when it is pushed out later?

#6 lore raw

2011/2/4 Junio C Hamano <[email protected]>:

Quoted 8 lines
Quoted 2 lines · Nguyễn Thái Ngọc Duy

 On top of nd/struct-pathspec, but requires jj/icase-directory. I can rebase the series on top of master if it causes too many conflicts.

I am in the middle of rewinding 'next' and have already rebased the topic; I will queue the result in 'pu' so could you check the result when it is pushed out later?

Checked. Looks good to me.

Signature · 1 line
Duy