]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t1006: accommodate for symlink support in MSYS2
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 17 Dec 2025 14:18:43 +0000 (14:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2025 23:18:13 +0000 (08:18 +0900)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1006-cat-file.sh

index 1f61b666a7d382d4deb65ad561f270409f826e48..0eee3bb8781b304967f2dd1bf038b7ddf0f5e2a9 100755 (executable)
@@ -1048,18 +1048,28 @@ test_expect_success 'git cat-file --batch-check --follow-symlinks works for out-
        echo .. >>expect &&
        echo HEAD:dir/subdir/out-of-repo-link-dir | git cat-file --batch-check --follow-symlinks >actual &&
        test_cmp expect actual &&
-       echo symlink 3 >expect &&
-       echo ../ >>expect &&
+       if test_have_prereq MINGW,SYMLINKS
+       then
+               test_write_lines "symlink 2" ..
+       else
+               test_write_lines "symlink 3" ../
+       fi >expect &&
        echo HEAD:dir/subdir/out-of-repo-link-dir-trailing | git cat-file --batch-check --follow-symlinks >actual &&
        test_cmp expect actual
 '
 
 test_expect_success 'git cat-file --batch-check --follow-symlinks works for symlinks with internal ..' '
-       echo HEAD: | git cat-file --batch-check >expect &&
-       echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
-       test_cmp expect actual &&
-       echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
-       test_cmp expect actual &&
+       if test_have_prereq !MINGW
+       then
+               # The `up-down` and `up-down-trailing` symlinks are normalized
+               # in MSYS in `winsymlinks` mode and are therefore in a
+               # different shape than Git expects them.
+               echo HEAD: | git cat-file --batch-check >expect &&
+               echo HEAD:up-down | git cat-file --batch-check --follow-symlinks >actual &&
+               test_cmp expect actual &&
+               echo HEAD:up-down-trailing | git cat-file --batch-check --follow-symlinks >actual &&
+               test_cmp expect actual
+       fi &&
        echo HEAD:up-down-file | git cat-file --batch-check --follow-symlinks >actual &&
        test_cmp found actual &&
        echo symlink 7 >expect &&