Skip to content

Commit 15cef7c

Browse files
committed
Merge branch 'js/icase-wt-detection' into maint
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 14f1467 + 63ec5e1 commit 15cef7c

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)