Skip to content

Commit 426450a

Browse files
committed
abspath_part_inside_repo: respect core.fileMode
If the file system is case-insensitive, we really must be careful to ignore differences in case only. This fixes git-for-windows#735 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6cd8528 commit 426450a

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

setup.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static int abspath_part_inside_repo(char *path)
3939
off = offset_1st_component(path);
4040

4141
/* 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)) {
4343
if (path[wtlen] == '/') {
4444
memmove(path, path + wtlen + 1, len - wtlen);
4545
return 0;
@@ -59,7 +59,7 @@ static int abspath_part_inside_repo(char *path)
5959
path++;
6060
if (*path == '/') {
6161
*path = '\0';
62-
if (strcmp(real_path(path0), work_tree) == 0) {
62+
if (fspathcmp(real_path(path0), work_tree) == 0) {
6363
memmove(path0, path + 1, len - (path - path0));
6464
return 0;
6565
}
@@ -68,7 +68,7 @@ static int abspath_part_inside_repo(char *path)
6868
}
6969

7070
/* check whole path */
71-
if (strcmp(real_path(path0), work_tree) == 0) {
71+
if (fspathcmp(real_path(path0), work_tree) == 0) {
7272
*path0 = '\0';
7373
return 0;
7474
}

t/t3700-add.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,4 +402,11 @@ test_expect_success 'all statuses changed in folder if . is given' '
402402
test $(git ls-files --stage | grep ^100755 | wc -l) -eq 0
403403
'
404404

405+
test_expect_success MINGW 'path is case-insensitive' '
406+
path="$(pwd -W)/BLUB" &&
407+
touch "$path" &&
408+
downcased="$(echo "$path" | tr A-Z a-z)" &&
409+
git add "$downcased"
410+
'
411+
405412
test_done

0 commit comments

Comments
 (0)