Skip to content

Commit

Permalink
Merge branch 'js/icase-wt-detection' into maint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gitster committed Oct 16, 2015
2 parents 14f1467 + 63ec5e1 commit 15cef7c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion dir.c
Expand Up @@ -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
Expand All @@ -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++;
Expand Down

0 comments on commit 15cef7c

Please sign in to comment.