Skip to content

Commit c2fdcf2

Browse files
committed
t0001: fix on case-insensitive filesystems
On a case-insensitive filesystem, such as HFS+ or NTFS, it is possible that the idea Bash has of the current directory differs in case from what Git thinks it is. That's totally okay, though, and we should not expect otherwise. On Windows, for example, when you call cd C:\GIT-SDK-64 in a PowerShell and there exists a directory called `C:\git-sdk-64`, the current directory will be reported in all upper-case. Even in a Bash that you might call from that PowerShell. Git, however, will have normalized this via `GetFinalPathByHandle()`, and the expectation in t0001 that the recorded gitdir will match what `pwd` says will be violated. Let's address this by forcing the comparison to be case-insensitive when `core.ignoreCase` is `true`. Reported by Jameson Miller. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 8104ec9 commit c2fdcf2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/t0001-init.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,22 @@ test_expect_success 'init prefers command line to GIT_DIR' '
307307
test_path_is_missing otherdir/refs
308308
'
309309

310+
downcase_on_case_insensitive_fs () {
311+
test true = "$(git config --get --type=bool core.ignorecase)" ||
312+
return 0
313+
314+
for f
315+
do
316+
tr A-Z a-z <"$f" >"$f".downcased &&
317+
mv -f "$f".downcased "$f" || return 1
318+
done
319+
}
320+
310321
test_expect_success 'init with separate gitdir' '
311322
rm -rf newdir &&
312323
git init --separate-git-dir realgitdir newdir &&
313324
echo "gitdir: $(pwd)/realgitdir" >expected &&
325+
downcase_on_case_insensitive_fs expected newdir/.git &&
314326
test_cmp expected newdir/.git &&
315327
test_path_is_dir realgitdir/refs
316328
'
@@ -365,6 +377,7 @@ test_expect_success 're-init to update git link' '
365377
git init --separate-git-dir ../surrealgitdir
366378
) &&
367379
echo "gitdir: $(pwd)/surrealgitdir" >expected &&
380+
downcase_on_case_insensitive_fs expected newdir/.git &&
368381
test_cmp expected newdir/.git &&
369382
test_path_is_dir surrealgitdir/refs &&
370383
test_path_is_missing realgitdir/refs
@@ -378,6 +391,7 @@ test_expect_success 're-init to move gitdir' '
378391
git init --separate-git-dir ../realgitdir
379392
) &&
380393
echo "gitdir: $(pwd)/realgitdir" >expected &&
394+
downcase_on_case_insensitive_fs expected newdir/.git &&
381395
test_cmp expected newdir/.git &&
382396
test_path_is_dir realgitdir/refs
383397
'

0 commit comments

Comments
 (0)