Skip to content

Commit 8a7c68b

Browse files
committed
t1006: accommodate for symlink support in MSYS2
The MSYS2 runtime (which inherits this trait from the Cygwin runtime, and which is used by Git for Windows' Bash to emulate POSIX functionality on Windows, the same Bash that is also used to run Git's test suite on Windows) has a mode where it can create native symbolic links on Windows. Naturally, this is a bit of a strange feature, given that Cygwin goes out of its way to support Unix-like paths even if no Win32 program understands those, and the symbolic links have to use Win32 paths instead (which Win32 programs understand very well). As a consequence, the symbolic link targets get normalized before the links are created. This results in certain quirks that Git's test suite is ill equipped to accommodate (because Git's test suite expects to be able to use Unix-like paths even on Windows). The test script t1006-cat-file.sh contains two prime examples, two test cases that need to skip a couple assertions because they are simply wrong in the context of Git for Windows. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 0866db0 commit 8a7c68b

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

t/t1006-cat-file.sh

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,18 +1048,28 @@ test_expect_success 'git cat-file --batch-check --follow-symlinks works for out-
10481048
echo .. >>expect &&
10491049
echo HEAD:dir/subdir/out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks >actual &&
10501050
test_cmp expect actual &&
1051-
echo symlink 3 >expect &&
1052-
echo ../ >>expect &&
1051+
if test_have_prereq MINGW,SYMLINKS
1052+
then
1053+
test_write_lines "symlink 2" ..
1054+
else
1055+
test_write_lines "symlink 3" ../
1056+
fi >expect &&
10531057
echo HEAD:dir/subdir/out-of-repo-link-dir-trailing | git cat-file --batch-check --follow-symlinks >actual &&
10541058
test_cmp expect actual
10551059
'
10561060

10571061
test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' '
1058-
echo HEAD: | git cat-file --batch-check >expect &&
1059-
echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
1060-
test_cmp expect actual &&
1061-
echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
1062-
test_cmp expect actual &&
1062+
if test_have_prereq !MINGW
1063+
then
1064+
# The `up-down` and `up-down-trailing` symlinks are normalized
1065+
# in MSYS in `winsymlinks` mode and are therefore in a
1066+
# different shape than Git expects them.
1067+
echo HEAD: | git cat-file --batch-check >expect &&
1068+
echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
1069+
test_cmp expect actual &&
1070+
echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
1071+
test_cmp expect actual
1072+
fi &&
10631073
echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks >actual &&
10641074
test_cmp found actual &&
10651075
echo symlink 7 >expect &&

0 commit comments

Comments
 (0)