Setting a global hooks path causes "Cowardly refusing to install" everywhere

See original GitHub issue

I recently setup a global spell checking commit hook that lives in

git config --global core.hooksPath ~/dotfiles/gitHooks

Just noticed that due to this, attempting pre-commit install now fails with

[ERROR] Cowardly refusing to install hooks with `core.hooksPath` set.

in every repo.

Is there actually a reason to fail in the presence of global hooks? Local hooks are still executed unless they’re being shadowed by a global hook of the same name, i.e. a global commit-msg hook would prevent a local commit-msg hook from running. In that case, it’s the user’s responsibility to make sure the global hook calls the local one if so desired.

If there is indeed no reason not to let global and local hooks coincide, fixing this might be as easy as modifying

def has_core_hookpaths_set():
-    _, out, _ = cmd_output_b('git', 'config', 'core.hooksPath', retcode=None)
+    _, out, _ = cmd_output_b('git', 'config', '--local', 'core.hooksPath', retcode=None)
    return bool(out.strip())

Happy to submit a PR for that.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
damienrjcommented, Jan 29, 2020

I played around with it for awhile this afternoon, and it appears that hooksPath, even locally in the repo with .git/config that it wasn’t triggering. Not quite sure why. Probably best to have the error as per patch. What ended up working was an alias pre-commit && git commit

1reaction
asottilecommented, Jan 29, 2020

🤷‍♂ ah well, I can possibly revert that later if someone mentions it – for now it’s been released as part of 2.0.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cowardly refusing to install hooks with `core.hooksPath` set
Run: git config --unset-all core.hooksPath. If the global core.hooksPath is not empty, run: git config --global --unset-all core.hooksPath.
Read more >
azu on Twitter: "あれ? --globalも呼ばれる? "Setting a global ...
Setting a global hooks path causes "Cowardly refusing to install" everywhere · Issue #1198 ·... I recently setup a global spell checking commit ......
Read more >
[ERROR] Cowardly refusing to install hooks with `core ...
hooksPath` set. Dear Interweb, I've stumbled upon `pre-commit`, a tool, or rather framework to manage your pre-commit Git hooks.
Read more >
GitPython Documentation - Read the Docs
Installing GitPython is easily done using pip. ... Returns path to the given named hook in the given git repository directory. 3.14 Index....
Read more >
Oedipus Background Information
Gradually Thebes succumbs to a vile plague, which kills animals, children and crops alike. Oedipus, the king, promises to save his city. Plagues...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found