Open ukch opened 2 years ago
I did a little investigation as to how git gui calls git hooks, and it looks like it doesn't use git itself; but instead builds the builds the path to the hook file by joining gitdir
, "hooks", and "hook_name".
I believe to fix this bug, the githook_read
in "./git-gui.sh
would need to be modified to first read if core.hooksPath
is set.
I don't know TCL at all otherwise I'd open a PR to read the config first.
I think allowing git gui to read core.hooksPath
would also fix: https://github.com/typicode/husky/issues/1041
Any update on this? It seems to be a pretty simple fix...
There has been a patch submission to the git mailing list that should fix this.
https://lore.kernel.org/git/20230917192431.101775-1-mlevedahl@gmail.com/T/#u
Tools such as Husky work by storing pre-commit and other git hooks in their own directory (in this case,
.husky
) and by settingcore.hooksPath
in the config to point to that directory instead of the default.git/hooks
. This tool, however, does not see those hooks and it is possible to accidentally bypass git hooks by using git-gui.To reproduce:
npm init
) inside a git reponpm install husky
)npx husky add pre-commit false && npx husky install
- this creates a.husky/pre-commit
hook which will always failgit gui
: the pre-commit hook is not runWorkaround:
.husky
to.git/hooks