Skip to content

Commit 6652939

Browse files
committed
Merge branch 'js/icase-wt-detection'
On a case insensitive filesystems, setting GIT_WORK_TREE variable using a random cases that does not agree with what the filesystem thinks confused Git that it wasn't inside the working tree. * js/icase-wt-detection: setup: fix "inside work tree" detection on case-insensitive filesystems
2 parents 7f11b48 + 63ec5e1 commit 6652939

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
@@ -2107,6 +2107,15 @@ int file_exists(const char *f)
21072107
return lstat(f, &sb) == 0;
21082108
}
21092109

2110+
static int cmp_icase(char a, char b)
2111+
{
2112+
if (a == b)
2113+
return 0;
2114+
if (ignore_case)
2115+
return toupper(a) - toupper(b);
2116+
return a - b;
2117+
}
2118+
21102119
/*
21112120
* Given two normalized paths (a trailing slash is ok), if subdir is
21122121
* outside dir, return -1. Otherwise return the offset in subdir that
@@ -2118,7 +2127,7 @@ int dir_inside_of(const char *subdir, const char *dir)
21182127

21192128
assert(dir && subdir && *dir && *subdir);
21202129

2121-
while (*dir && *subdir && *dir == *subdir) {
2130+
while (*dir && *subdir && !cmp_icase(*dir, *subdir)) {
21222131
dir++;
21232132
subdir++;
21242133
offset++;

0 commit comments

Comments
 (0)