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

From: Junio C Hamano <[email-masked]>
Date: Tue, 27 May 2025 10:19:53 -0700

Mark Mentovai <[email-masked]> writes:

> Forcing the entire test suite to run from a realpath-canonicalized
> path seems like a blunt instrument, though.

I view it differently.

It is a very effective way to make sure that the tests work for one
person does not mysteriously break for another, only due to where
they kept the git repository and where in their filesystem they
arranged the tests to run.  That is not the kind of breakage we want
our developers to be scratching their heads about.

The part of the test-lib I showed already was trying to make sure
that our idea of $PWD matches the physical world.  It did so only
for PWD, by doing 'cd -P "$TRASH_DIRECTORY"' early in the test setup
sequence, but it did so after setting HOME, leaving it inconsistent
between physical and logical world.

Which is the bug that my suggested fix addresses.

Besides the problem we saw in this discussion thread is *not* a bug
in Git and its normalization of its working directory, is it?  It
was a bug in the test script that assumed that $HOME already was
normalized, right?

If we want to make sure Git (not its tests, but Git itself) works
when (pwd) and (pwd -P) are different, we should have a dedicated
test to arrange that for everybody, regardless of where the tester
checks out their git repository.  We can only do so on symlink
capable filesystems, but we do have enough support in the test
framework to do so if you want to write such a test.