1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-10-30 13:57:54 +01:00

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
This commit is contained in:
Junio C Hamano 2015-10-16 14:32:46 -07:00
commit 15cef7ccd9

11
dir.c
View file

@ -2030,6 +2030,15 @@ int file_exists(const char *f)
return lstat(f, &sb) == 0;
}
static int cmp_icase(char a, char b)
{
if (a == b)
return 0;
if (ignore_case)
return toupper(a) - toupper(b);
return a - b;
}
/*
* Given two normalized paths (a trailing slash is ok), if subdir is
* 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)
assert(dir && subdir && *dir && *subdir);
while (*dir && *subdir && *dir == *subdir) {
while (*dir && *subdir && !cmp_icase(*dir, *subdir)) {
dir++;
subdir++;
offset++;