Lazygit hangs after branch checkout command due to interactive git hook
Describe the bug
Lazygit hangs in checking out state when there is interactive post-checkout git hook
To Reproduce Steps to reproduce the behavior:
- Setup a git repository with an interactive post-checkout hook
echo 'exec </dev/tty && read line || true' > .git/hooks/post-checkout
chmod u+x .git/hook/post-checkout
- Open lazygit, and go to 'Branches' pane
- Checkout branch
- Lazygit hangs in 'Checking out' the branch
Expected behavior Lazygit shouldn't hang on checkout, possible behaviors:
- provide user control to interact with the git hook stdin.
- terminate the git hook once checkout is done.
Screenshots
Status 'Checking out' doesn't change
Version info: Lazygit: commit=, build date=, build source=nix, version=0.41.0, os=darwin, arch=arm64, git version=2.44.0
Additional context
I saw how you handle credential requests sync.go#Pull, maybe it would make sense to give user access to stdin when a command is interactive as in edit command.
Just noticed this as well. We have a git hook that wants to request that a checklist is covered before pushing. The user is supposed to say "y" at tty when answering checklist items. We'd prefer to do it on the CLI rather than resort to adding the checklists as a Github extension.
exec < /dev/tty
while true; do
read -p "[pre-push hook] Have you viewed the change or feature in-app before pushing? (Y/n) " yn
if [ "$yn" = "" ]; then
yn='Y'
fi
case $yn in
[Yy] ) exit 0;;
[Nn] ) exit 1;;
* ) echo "Please answer y or n for yes or no.";;
esac
done
Hello wonderful people. Is this being looked at? I'm new to using lazygit, but wanted to contribute to this discussion given that I have a heavily customized git configuration which constantly breaks if enabled, unfortunately. :( If not for these hooks and GPG signing, lazygit would literally be the best thing since the invention of chairs.
My configuration includes, ssh keys with password configured, GPG signing, and pre-commit, commit-msg and pre-push hooks, which constantly require interaction from the user. I've disabled GPG signing and created a pre-push hook to disallow pushing unsigned commits, and this solves the problem of using GPG signing while using lazygit, but I feel reluctant about disabling hooks entirely. I'd rather be notified that a problem occured in any of the intermediate steps so that I can take steps to fix it.
This would be especially useful during patch creation (the best feature of lazygit, imo).