abspath_part_inside_repo: respect core.ignoreCase
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Fri, 18 Jan 2019 13:24:54 +0000 (05:24 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 18 Jan 2019 17:53:06 +0000 (09:53 -0800)
If the file system is case-insensitive, we really must be careful to
ignore differences in case only.

This fixes https://github.com/git-for-windows/git/issues/735

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
setup.c
t/t3700-add.sh
diff --git a/setup.c b/setup.c
index 1be5037f129646cd46d3dc048e8f58dc3bdac0b9..291bfb2128c1b51bfe59c3a24cd8753466a42e17 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -39,7 +39,7 @@ static int abspath_part_inside_repo(char *path)
        off = offset_1st_component(path);
 
        /* check if work tree is already the prefix */
-       if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
+       if (wtlen <= len && !fspathncmp(path, work_tree, wtlen)) {
                if (path[wtlen] == '/') {
                        memmove(path, path + wtlen + 1, len - wtlen);
                        return 0;
@@ -59,7 +59,7 @@ static int abspath_part_inside_repo(char *path)
                path++;
                if (*path == '/') {
                        *path = '\0';
-                       if (strcmp(real_path(path0), work_tree) == 0) {
+                       if (fspathcmp(real_path(path0), work_tree) == 0) {
                                memmove(path0, path + 1, len - (path - path0));
                                return 0;
                        }
@@ -68,7 +68,7 @@ static int abspath_part_inside_repo(char *path)
        }
 
        /* check whole path */
-       if (strcmp(real_path(path0), work_tree) == 0) {
+       if (fspathcmp(real_path(path0), work_tree) == 0) {
                *path0 = '\0';
                return 0;
        }
index 37729ba2582119047d559d22df8c522f9c0ab0f1..be582a513b1b99a71c10279aacc72cb36bd4bf7b 100755 (executable)
@@ -402,4 +402,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
        test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
 '
 
+test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
+       path="$(pwd)/BLUB" &&
+       touch "$path" &&
+       downcased="$(echo "$path" | tr A-Z a-z)" &&
+       git add "$downcased"
+'
+
 test_done