Subject: Re: [PATCH] t7900: use pwd -P in macOS maintenance test

From: Junio C Hamano <[email-masked]>
Date: Fri, 23 May 2025 14:51:44 -0700

Eric Sunshine <[email-masked]> writes:

> Hmm, I'm not sure how that would help this particular case which wants
> to know the path of $HOME:
>
>     pfx=$(cd "$HOME" && pwd -P) &&

We set HOME to TRASH_DIRECTORY during test, so HOME would not be all
that special.

I thought one of the issues was on Windows "-P" in "pwd -P" is a
no-op?  So if you want to fix it locally perhaps

    pfx=$(cd -P "$HOME" && pwd)

but I think the true issue may be that we set up fake HOME using
TRASH_DIRECTORY that is before we canonicalize it with "cd -P".

Would doing something like this (without any other changes we
discussed so far) help?

 t/test-lib.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git c/t/test-lib.sh w/t/test-lib.sh
index af722d383d..92d0db13d7 100644
--- c/t/test-lib.sh
+++ w/t/test-lib.sh
@@ -1577,6 +1577,8 @@ fi
 # Use -P to resolve symlinks in our working directory so that the cwd
 # in subprocesses like git equals our $PWD (for pathname comparisons).
 cd -P "$TRASH_DIRECTORY" || BAIL_OUT "cannot cd -P to \"$TRASH_DIRECTORY\""
+TRASH_DIRECTORY=$(pwd)
+HOME="$TRASH_DIRECTORY"
 
 start_test_output "$0"