Merge branch 'js/icase-wt-detection' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 16 Oct 2015 21:32:46 +0000 (14:32 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 16 Oct 2015 21:32:46 +0000 (14:32 -0700)
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

1  2 
dir.c
diff --combined dir.c
index 7b25634832716ade46686d118184c4d43d8c11e7,22402c730efdf7b4f5e4f4c2527d94c22a96b3d9..118ba59a27f51d1966c03faa8c36627a0a8d6246
--- 1/dir.c
--- 2/dir.c
+++ b/dir.c
@@@ -2030,6 -2030,15 +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 +2050,7 @@@ int dir_inside_of(const char *subdir, c
  
        assert(dir && subdir && *dir && *subdir);
  
-       while (*dir && *subdir && *dir == *subdir) {
+       while (*dir && *subdir && !cmp_icase(*dir, *subdir)) {
                dir++;
                subdir++;
                offset++;
@@@ -2176,8 -2185,6 +2185,8 @@@ int remove_dir_recursively(struct strbu
        return remove_dir_recurse(path, flag, NULL);
  }
  
 +static GIT_PATH_FUNC(git_path_info_exclude, "info/exclude")
 +
  void setup_standard_excludes(struct dir_struct *dir)
  {
        const char *path;
                                         dir->untracked ? &dir->ss_excludes_file : NULL);
  
        /* per repository user preference */
 -      path = git_path("info/exclude");
 +      path = git_path_info_exclude();
        if (!access_or_warn(path, R_OK, 0))
                add_excludes_from_file_1(dir, path,
                                         dir->untracked ? &dir->ss_info_exclude : NULL);