abspath_part_inside_repo: respect core.ignoreCase
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>
Johannes Schindelin committed
Jan 18, 2019 at 05:24 UTC
d8727b3687c1d249e84be71a581cc1fb0581336a
2 files changed
+10
-3
setup.c
+3
-3
@@ -39,7 +39,7 @@ static int abspath_part_inside_repo(char *path)
39
off = offset_1st_component(path);
40
41
/* check if work tree is already the prefix */
42
- if (wtlen <= len && !strncmp(path, work_tree, wtlen)) {
42
+ if (wtlen <= len && !fspathncmp(path, work_tree, wtlen)) {
43
if (path[wtlen] == '/') {
44
memmove(path, path + wtlen + 1, len - wtlen);
45
return 0;
@@ -59,7 +59,7 @@ static int abspath_part_inside_repo(char *path)
59
path++;
60
if (*path == '/') {
61
*path = '\0';
62
- if (strcmp(real_path(path0), work_tree) == 0) {
62
+ if (fspathcmp(real_path(path0), work_tree) == 0) {
63
memmove(path0, path + 1, len - (path - path0));
64
return 0;
65
}
@@ -68,7 +68,7 @@ static int abspath_part_inside_repo(char *path)
68
}
69
70
/* check whole path */
71
- if (strcmp(real_path(path0), work_tree) == 0) {
71
+ if (fspathcmp(real_path(path0), work_tree) == 0) {
72
*path0 = '\0';
73
return 0;
74
}
t/t3700-add.sh
+7
@@ -402,4 +402,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
402
test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
403
'
404
405
+test_expect_success CASE_INSENSITIVE_FS 'path is case-insensitive' '
406
+ path="$(pwd)/BLUB" &&
407
+ touch "$path" &&
408
+ downcased="$(echo "$path" | tr A-Z a-z)" &&
409
+ git add "$downcased"
410
+'
411
+
412
test_done