summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Peart <benpeart@microsoft.com>2018-02-08 19:23:33 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-02-08 20:20:56 (GMT)
commitc95525e90d2f3c75b879ce51fd17d263a6452de3 (patch)
tree80ef01e21e321ec56c9346bea8e664777ad3ba5e
parent27dea4683b608c5c0487dee74cbda13b62803b73 (diff)
downloadgit-c95525e90d2f3c75b879ce51fd17d263a6452de3.zip
git-c95525e90d2f3c75b879ce51fd17d263a6452de3.tar.gz
git-c95525e90d2f3c75b879ce51fd17d263a6452de3.tar.bz2
name-hash: properly fold directory names in adjust_dirname_case()
Correct the pointer arithmetic in adjust_dirname_case() so that it calls find_dir_entry() with the correct string length. Previously passing in "dir1/foo" would pass a length of 6 instead of the correct 4. This resulted in find_dir_entry() never finding the entry and so the subsequent memcpy that would fold the name to the version with the correct case never executed. Add a test to validate the corrected behavior with name folding of directories. Signed-off-by: Ben Peart <benpeart@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--name-hash.c6
-rwxr-xr-xt/t0050-filesystem.sh16
2 files changed, 18 insertions, 4 deletions
diff --git a/name-hash.c b/name-hash.c
index 6d9f23e..139263b 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -201,12 +201,12 @@ void adjust_dirname_case(struct index_state *istate, char *name)
if (*ptr == '/') {
struct dir_entry *dir;
- ptr++;
- dir = find_dir_entry(istate, name, ptr - name + 1);
+ dir = find_dir_entry(istate, name, ptr - name);
if (dir) {
memcpy((void *)startPtr, dir->name + (startPtr - name), ptr - startPtr);
- startPtr = ptr;
+ startPtr = ptr + 1;
}
+ ptr++;
}
}
}
diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh
index b29d749..192c94e 100755
--- a/t/t0050-filesystem.sh
+++ b/t/t0050-filesystem.sh
@@ -80,7 +80,21 @@ test_expect_success 'merge (case change)' '
git merge topic
'
-
+test_expect_success CASE_INSENSITIVE_FS 'add directory (with different case)' '
+ git reset --hard initial &&
+ mkdir -p dir1/dir2 &&
+ echo >dir1/dir2/a &&
+ echo >dir1/dir2/b &&
+ git add dir1/dir2/a &&
+ git add dir1/DIR2/b &&
+ git ls-files >actual &&
+ cat >expected <<-\EOF &&
+ camelcase
+ dir1/dir2/a
+ dir1/dir2/b
+ EOF
+ test_cmp expected actual
+'
test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
git reset --hard initial &&