]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t0001: handle `diff --no-index` gracefully
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 17 Dec 2025 14:18:40 +0000 (14:18 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Dec 2025 23:18:13 +0000 (08:18 +0900)
The test case 're-init to move gitdir symlink' wants to compare the
contents of `newdir/.git`, which is a symbolic link pointing to a file.
However, `git diff --no-index`, which is used by `test_cmp` on Windows,
does not resolve symlinks; It shows the symlink _target_ instead (with a
file mode of 120000). That is totally unexpected by the test case, which
as a consequence fails, meaning that it's a bug in the test case itself.

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

index 618da080dc9ea9564fade0e6f2570df3f90b933c..e4d32bb4d259f66523180e9bf0a4befb2c8cb011 100755 (executable)
@@ -425,7 +425,11 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' '
        git init --separate-git-dir ../realgitdir
        ) &&
        echo "gitdir: $(pwd)/realgitdir" >expected &&
-       test_cmp expected newdir/.git &&
+       case "$GIT_TEST_CMP" in
+       # `git diff --no-index` does not resolve symlinks
+       *--no-index*) cmp expected newdir/.git;;
+       *) test_cmp expected newdir/.git;;
+       esac &&
        test_cmp expected newdir/here &&
        test_path_is_dir realgitdir/refs
 '