Description
Describe the bug
If a repo implements a prepare-commit-msg which requires user input gitui will hang on various operations that trigger the hook (commit, rebase, merge, cherry pick).
This is a pretty common pattern in repos using commitizen as one of the options that the project recommends is using prepare-commit-msg
To Reproduce
minimal example here: https://github.com/jaredmcateer/cz-gitui
Steps to reproduce the behavior:
- Open repo with prepare-commit-msg that requires user input
- Add/Modify a file
- Stage file
- Go to 'staged change' in gitui
- Press 'c'
- Observe gitui is unresponsive
Screenshots
In your processes you will see something like this:
Context (please complete the following information):
- OS/Distro + Version: tested on Mac OS Sonoma 14.7.1 & Pop_OS! 22.0.4 LTS
- GitUI Version: gitui nightly 2025-03-04 ()
- Rust version: rustc 1.82.0 (f6e511eec 2024-10-15)
Additional context
Lazygit also suffers from this, and the current workaround is to override all the commit-like commands with custom keybindings to disable Husky, but that will also kill other useful things like pre-commit hooks that run tests/linters.
Activity
DaRacci commentedon Mar 5, 2025
this sounds like a near impossible issue to fix, the easy solution might be adding a timeout to the command invocation.
extrawurst commentedon Mar 5, 2025
@DaRacci i agree that is what we should do here. interested in giving this a go?
jaredmcateer commentedon Mar 5, 2025
FWIW I found lazygit allows committing via the system editor with shift+c which does allow gracefully handling the hook, but they have no functionality for the other commands that trigger the
prepare-commit-msg
hook and cause it to hang as well. You can also build custom menu/commands that run in a subprocess that other users are reporting works for them but I haven't dug into that.I understand if this is too much work. I tend to agree with the sentiment that what commitizen is doing is going against the spirit of git hooks. I just happen to work on a lot of repos that aren't mine with it and having my TUI frozen trying to do something like a rebase drives me a bit batty, so at least having a timeout is better than having to kill the process and reset my terminal.
DaRacci commentedon Mar 13, 2025
how does using the system editor allow these hooks to work, i may not quite be following could you record a clip of how this functions?
jaredmcateer commentedon Mar 14, 2025
Yea sure. Sorry I'm on wayland and I haven't quite figured out how to get something going that shows my key presses in screencasts but basically I stage the file, press shift+c it switches the the terminal where I can follow commitizens prompts, it then drops me into my
$EDITOR
(nvim) to make any additional changes and then:wq
to save and commit, then I'm back in the terminal and when I press any button I'm brought back into lazygit.lazygit.webm
DaRacci commentedon Mar 15, 2025
Thanks for the demo, I was hoping this would give a lead but it seems like its just dropping you into a shell where git commit has been ran.