From: Ben Peart <benpeart@microsoft.com>
To: git@vger.kernel.org
Cc: prohaska@zib.de, gitster@pobox.com, tboegi@web.de,
sunshine@sunshineco.com, novalis@novalis.org,
Ben Peart <benpeart@microsoft.com>
Subject: [PATCH v1] name-hash: properly fold directory names in adjust_dirname_case()
Date: Wed, 7 Feb 2018 19:41:56 -0500 [thread overview]
Message-ID: <20180208004156.36224-1-benpeart@microsoft.com> (raw)
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>
---
Notes:
Base Ref: v2.16.1
Web-Diff: https://github.com/benpeart/git/commit/2944970f4e
Checkout: git fetch https://github.com/benpeart/git adjust_dirname-v1 && git checkout 2944970f4e
name-hash.c | 6 +++---
t/t0050-filesystem.sh | 12 +++++++++++-
2 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/name-hash.c b/name-hash.c
index 45c98db0a0..2ddbb72647 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -696,12 +696,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 b29d749bb7..219c96594c 100755
--- a/t/t0050-filesystem.sh
+++ b/t/t0050-filesystem.sh
@@ -80,7 +80,17 @@ 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 &&
+ mkdir -p dir1/dir2 &&
+ touch dir1/dir2/a &&
+ touch dir1/dir2/b &&
+ git add dir1/dir2/a &&
+ git add dir1/DIR2/b &&
+ camel=$(git ls-files | grep dir2) &&
+ test $(echo "$camel" | wc -l) = 2
+'
test_expect_failure CASE_INSENSITIVE_FS 'add (with different case)' '
git reset --hard initial &&
base-commit: 8279ed033f703d4115bee620dccd32a9ec94d9aa
--
2.15.0.windows.1
next reply other threads:[~2018-02-08 0:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-08 0:41 Ben Peart [this message]
2018-02-08 1:02 ` [PATCH v1] name-hash: properly fold directory names in adjust_dirname_case() David Turner
2018-02-08 17:21 ` Torsten Bögershausen
2018-02-08 17:45 ` Ben Peart
2018-02-08 18:24 ` Junio C Hamano
2018-02-08 18:20 ` Junio C Hamano
2018-02-08 19:23 ` [PATCH v2] " Ben Peart
2018-02-09 5:43 ` Torsten Bögershausen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180208004156.36224-1-benpeart@microsoft.com \
--to=benpeart@microsoft.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=novalis@novalis.org \
--cc=prohaska@zib.de \
--cc=sunshine@sunshineco.com \
--cc=tboegi@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).