Re: [PATCH 04/10] t0001: handle `diff --no-index` gracefully
From: Johannes Schindelin <hidden>
Date: 2025-12-01 13:20:31
Hi Junio, On Sat, 29 Nov 2025, Junio C Hamano wrote:
"Johannes Schindelin via GitGitGadget" [off-list ref] writes:quoted
From: Johannes Schindelin <redacted> 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.It is dubious if it is a bug in this particular test case, or test_cmp implementation that uses "git diff --no-index", though. Either way, when test_cmp here does not do "diff", the test would fail, so you are correct to notice that this piece of code needs to be patched in some way. I do not think not comparing is the right solution, though. Would there be a better option than completely punting on the comparison? Something silly like:quoted
+ 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 &&perhaps?
Sure. It's not like this adds much confidence, though, as the tested-for functionality isn't specific to Windows, so I'd expect this to fail on Linux, too, if it was broken, and running that comparison on Windows does not add much. Since you spent time on this, I will change it, though. Ciao, Johannes
quoted
Signed-off-by: Johannes Schindelin <redacted> --- t/t0001-init.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)diff --git a/t/t0001-init.sh b/t/t0001-init.sh index 618da080dc..2f38e09b58 100755 --- a/t/t0001-init.sh +++ b/t/t0001-init.sh@@ -425,7 +425,10 @@ 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 + *--no-index*) ;; # git diff --no-index does not resolve symlinks + *) test_cmp expected newdir/.git;; + esac && test_cmp expected newdir/here && test_path_is_dir realgitdir/refs '