]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t7800: work around the MSYS path conversion on Windows
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 17 Dec 2025 14:18:46 +0000 (14:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2025 23:18:14 +0000 (08:18 +0900)
Git's test suite's relies on Unix shell scripting, which is
understandable, of course, given Git's firm roots (and indeed, ongoing
focus) on Linux.

This fact, combined with Unix shell scripting's natural
habitat -- which is, naturally... *drumroll*... Unix --
often has unintended side effects, where developers expect the test
suite to run in a Unix environment, which is an incorrect assumption.

One instance of this problem can be observed in the 'difftool --dir-diff
handles modified symlinks' test case in `t7800-difftool.sh`, which
assumes that all absolute paths start with a forward slash. That
assumption is incorrect in general, e.g. on Windows, where absolute
paths have many shapes and forms, none of which starts with a forward
slash.

The only saving grace is that this test case is currently not run on
Windows because of the `SYMLINK` prerequisite. However, I am currently
working towards upstreaming symbolic link support from Git for Windows
to upstream Git, which will put a crack into that saving grace.

Let's change that test case so that it does not rely on absolute paths
(which are passed to the "external command" `ls` as parameters and are
therefore part of its output, and which the test case wants to filter
out before verifying that the output is as expected) starting with a
forward slash. Let's instead rely on the much more reliable fact that
`ls` will output the path in a line that ends in a colon, and simply
filter out those lines by matching said colon instead.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t7800-difftool.sh

index 9b74db55634b16d5d1eb2bb93471c8d62c73d93a..bf0f67378dbb239075650dd7b8bff78b4374cf9a 100755 (executable)
@@ -752,11 +752,11 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
                c
        EOF
        git difftool --symlinks --dir-diff --extcmd ls >output &&
-       grep -v ^/ output >actual &&
+       grep -v ":\$" output >actual &&
        test_cmp expect actual &&
 
        git difftool --no-symlinks --dir-diff --extcmd ls >output &&
-       grep -v ^/ output >actual &&
+       grep -v ":\$" output >actual &&
        test_cmp expect actual &&
 
        # The left side contains symlink "c" that points to "b"
@@ -786,11 +786,11 @@ test_expect_success SYMLINKS 'difftool --dir-diff handles modified symlinks' '
 
        EOF
        git difftool --symlinks --dir-diff --extcmd ls >output &&
-       grep -v ^/ output >actual &&
+       grep -v ":\$" output >actual &&
        test_cmp expect actual &&
 
        git difftool --no-symlinks --dir-diff --extcmd ls >output &&
-       grep -v ^/ output >actual &&
+       grep -v ":\$" output >actual &&
        test_cmp expect actual
 '