I also encountered this issue today; I am running Pop!_OS 22.04 and could reproduce it with git 2.34.1 (latest).
After updating to the latest stable Git using:
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt upgrade
# ...
Setting up git (1:2.49.0-2~ppa1~ubuntu22.04.1) ...
Setting up gitk (1:2.49.0-2~ppa1~ubuntu22.04.1) ...
# ...
and git --version
reporting git version 2.49.0
I can confirm that this no longer reproduces.
The safe_open_command_redirect
seems to only have been introduced since Git 2.43.7 (https://github.com/git/git/commit/67a128b91e25978a15f9f7e194d81b441d603652), so I have no idea why gitk
executed that in both our cases.
Maybe there was a mismatch when package maintainers updated the git
/gitk
packages?
In any case, updating the Git to latest stable seems to side-step this issue for now (but I'm sure that the package maintainers will fix this in the meantime).