Skip to content

Commit 1f0ceee

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 comparing these paths in a case-insensitive manner when `core.ignoreCase` is `true`. Reported by Jameson Miller. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8104ec9 commit 1f0ceee

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

t/t0001-init.sh

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ test_expect_success 'init prefers command line to GIT_DIR' '
310310
test_expect_success 'init with separate gitdir' '
311311
rm -rf newdir &&
312312
git init --separate-git-dir realgitdir newdir &&
313-
echo "gitdir: $(pwd)/realgitdir" >expected &&
314-
test_cmp expected newdir/.git &&
313+
newdir_git="$(cat newdir/.git)" &&
314+
test_cmp_fspath "$(pwd)/realgitdir" "${newdir_git#gitdir: }" &&
315315
test_path_is_dir realgitdir/refs
316316
'
317317

@@ -360,25 +360,19 @@ test_expect_success 're-init on .git file' '
360360
'
361361

362362
test_expect_success 're-init to update git link' '
363-
(
364-
cd newdir &&
365-
git init --separate-git-dir ../surrealgitdir
366-
) &&
367-
echo "gitdir: $(pwd)/surrealgitdir" >expected &&
368-
test_cmp expected newdir/.git &&
363+
git -C newdir init --separate-git-dir ../surrealgitdir &&
364+
newdir_git="$(cat newdir/.git)" &&
365+
test_cmp_fspath "$(pwd)/surrealgitdir" "${newdir_git#gitdir: }" &&
369366
test_path_is_dir surrealgitdir/refs &&
370367
test_path_is_missing realgitdir/refs
371368
'
372369

373370
test_expect_success 're-init to move gitdir' '
374371
rm -rf newdir realgitdir surrealgitdir &&
375372
git init newdir &&
376-
(
377-
cd newdir &&
378-
git init --separate-git-dir ../realgitdir
379-
) &&
380-
echo "gitdir: $(pwd)/realgitdir" >expected &&
381-
test_cmp expected newdir/.git &&
373+
git -C newdir init --separate-git-dir ../realgitdir &&
374+
newdir_git="$(cat newdir/.git)" &&
375+
test_cmp_fspath "$(pwd)/realgitdir" "${newdir_git#gitdir: }" &&
382376
test_path_is_dir realgitdir/refs
383377
'
384378

t/test-lib-functions.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,21 @@ test_cmp_rev () {
879879
fi
880880
}
881881

882+
# Compare paths respecting core.ignoreCase
883+
test_cmp_fspath () {
884+
if test "x$1" = "x$2"
885+
then
886+
return 0
887+
fi
888+
889+
if test true != "$(git config --get --type=bool core.ignorecase)"
890+
then
891+
return 1
892+
fi
893+
894+
test "x$(echo "$1" | tr A-Z a-z)" = "x$(echo "$2" | tr A-Z a-z)"
895+
}
896+
882897
# Print a sequence of integers in increasing order, either with
883898
# two arguments (start and end):
884899
#

0 commit comments

Comments
 (0)