Skip to content

Commit 254e6e8

Browse files
committed
Merge branch 'work-tree-icase'
This topic branch fixes the "is inside work tree" test when it fails solely due to lower/upper case differences despite the config setting `core.ignoreCase = true` (Git for Windows' default). Signed-off-by: Johannes Schindelin <[email protected]>
2 parents a369f32 + 18d3542 commit 254e6e8

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

dir.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,15 @@ int file_exists(const char *f)
20302030
return lstat(f, &sb) == 0;
20312031
}
20322032

2033+
static int cmp_icase(char a, char b)
2034+
{
2035+
if (a == b)
2036+
return 0;
2037+
if (ignore_case)
2038+
return toupper(a) - toupper(b);
2039+
return a - b;
2040+
}
2041+
20332042
/*
20342043
* Given two normalized paths (a trailing slash is ok), if subdir is
20352044
* outside dir, return -1. Otherwise return the offset in subdir that
@@ -2041,7 +2050,7 @@ int dir_inside_of(const char *subdir, const char *dir)
20412050

20422051
assert(dir && subdir && *dir && *subdir);
20432052

2044-
while (*dir && *subdir && *dir == *subdir) {
2053+
while (*dir && *subdir && !cmp_icase(*dir, *subdir)) {
20452054
dir++;
20462055
subdir++;
20472056
offset++;

0 commit comments

Comments
 (0)