]> Kevux Git Server - rit/commit
t5510: stop changing top-level working directory
authorJeff King <peff@peff.net>
Tue, 19 Aug 2025 19:26:06 +0000 (15:26 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 19 Aug 2025 23:06:02 +0000 (16:06 -0700)
commit1de2903c0f065b4c14326a741a57cc7e7b63610f
treea15b70dd85c68114bc95517b4642659f8ff3fa01
parent217e4a23d76fe95a0f6ab0f6159de2460db6fcd9
t5510: stop changing top-level working directory

Several tests in t5510 do a bare "cd subrepo", not in a subshell. This
changes the working directory for subsequent tests. As a result, almost
every test has to start with "cd $D" to go back to the top-level.

Our usual style is to do per-test environment changes like this in a
subshell, so that tests can assume they are starting at the top-level
$TRASH_DIRECTORY.

Let's switch to that style, which lets us drop all of that extra
path-handling.

Most cases can switch to using a subshell, but in a few spots we can
simplify by doing "git init foo && git -C foo ...". We do have to make
sure that we weren't intentionally touching the environment in any code
which was moved into a subshell (e.g., with a test_when_finished), but
that isn't the case for any of these tests.

All of the references to the $D variable can go away, replaced generally
with $PWD or $TRASH_DIRECTORY (if we use it inside a chdir'd subshell).
Note in one test, "fetch --prune prints the remotes url", we make sure
to use $(pwd) to get the Windows-style path on that platform (for the
other tests, the exact form doesn't matter).

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t5510-fetch.sh