Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not respect core.hooksPath #62

Open
ukch opened this issue Aug 5, 2021 · 3 comments
Open

Does not respect core.hooksPath #62

ukch opened this issue Aug 5, 2021 · 3 comments

Comments

@ukch
Copy link

ukch commented Aug 5, 2021

Tools such as Husky work by storing pre-commit and other git hooks in their own directory (in this case, .husky) and by setting core.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:

  • Start a new npm project (npm init) inside a git repo
  • Install husky (npm install husky)
  • Run npx husky add pre-commit false && npx husky install - this creates a .husky/pre-commit hook which will always fail
  • Attempt to commit using the command line: the pre-commit hook fails and the commit aborts
  • Attempt to commit using git gui: the pre-commit hook is not run

Workaround:

  • Symlink .husky to .git/hooks
@Naddiseo
Copy link

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: typicode/husky#1041

@piranna
Copy link

piranna commented Jun 29, 2023

Any update on this? It seems to be a pretty simple fix...

@rimrul
Copy link

rimrul commented Sep 18, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants