From c95525e90d2f3c75b879ce51fd17d263a6452de3 Mon Sep 17 00:00:00 2001 From: Ben Peart Date: Thu, 8 Feb 2018 14:23:33 -0500 Subject: 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 Signed-off-by: Junio C Hamano --- name-hash.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'name-hash.c') diff --git a/name-hash.c b/name-hash.c index 6d9f23e932..139263b5e0 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++; } } } -- cgit v1.2.3