Skip to content
Permalink
Browse files

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 #735

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
  • Loading branch information...
dscho committed Apr 5, 2017
1 parent 7723f38 commit 7df5db8d31e7b384b14e488c76933d46a9e76161
Showing with 10 additions and 3 deletions.
  1. +3 −3 setup.c
  2. +7 −0 t/t3700-add.sh
@@ -36,7 +36,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;
@@ -56,7 +56,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;
}
@@ -65,7 +65,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;
}
@@ -403,4 +403,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 MINGW 'path is case-insensitive' '
path="$(pwd -W)/BLUB" &&
touch "$path" &&
downcased="$(echo "$path" | tr A-Z a-z)" &&
git add "$downcased"
'

test_done

0 comments on commit 7df5db8

Please sign in to comment.
You can’t perform that action at this time.