summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-10-16 21:32:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-10-16 21:32:46 (GMT)
commit15cef7ccd93d790fbe162de66366c4878ddaf921 (patch)
tree9ec8ee6b3e5ffda4b55f451183690d40aa7ef389 /dir.c
parent14f1467493a8d4c094b5f07fa2564b7e1b0eb7bc (diff)
parent63ec5e1fecc14b0dd5452f0a2b80641600b03437 (diff)
downloadgit-15cef7ccd93d790fbe162de66366c4878ddaf921.zip
git-15cef7ccd93d790fbe162de66366c4878ddaf921.tar.gz
git-15cef7ccd93d790fbe162de66366c4878ddaf921.tar.bz2
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
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 7b25634..118ba59 100644
--- a/dir.c
+++ b/dir.c
@@ -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++;