]> git.ipfire.org Git - thirdparty/git.git/commit
t9164: fix inability to find basename(1) in Subversion hooks
authorPatrick Steinhardt <ps@pks.im>
Fri, 10 Nov 2023 08:17:09 +0000 (09:17 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 11 Nov 2023 00:00:42 +0000 (09:00 +0900)
commit0856f13abaea5f8d3915dd60e7221e108ce14fdf
tree0b5064f3ecf7035ab957387b21d0ca3ddaa5afc8
parent5d70afa5d81ee7bbd25e875512f9fc3824b096b6
t9164: fix inability to find basename(1) in Subversion hooks

Hooks executed by Subversion are spawned with an empty environment. By
default, not even variables like PATH will be propagated to them. In
order to ensure that we're still able to find required executables, we
thus write the current PATH variable into the hook script itself and
then re-export it in t9164.

This happens too late in the script though, as we already tried to
execute the basename(1) utility before exporting the PATH variable. This
tends to work on most platforms as the fallback value of PATH for Bash
(see `getconf PATH`) is likely to contain this binary. But on more
exotic platforms like NixOS this is not the case, and thus the test
fails.

While we could work around this issue by simply setting PATH earlier, it
feels fragile to inject a user-controlled value into the script and have
the shell interpret it. Instead, we can refactor the hook setup to write
a `hooks-env` file that configures PATH for us. Like this, Subversion
will know to set up the environment as expected for all hooks.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t9164-git-svn-dcommit-concurrent.sh