Re: Inaccurate documentation for core.hooksPath?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 23, 2024 at 03:36:49PM -0400, Mark Boyd - Q2AAAA wrote:

> This documentation says that git only looks for hooks in the
> configured core.hooksPath:
> https://github.com/git/git/blob/master/Documentation/config/core.txt#L499-L504
> 
> However, in my testing, git will run both hooks located in the
> core.hooksPath directory and in the local git repo hooks directory
> (.git/hooks by default). Observation of this behavior is documented in
> https://github.com/cloud-gov/caulking/issues/37.
> 
> Is the behavior I'm seeing the actually expected behavior of git? Or
> are we somehow relying on an edge-case or buggy behavior?

Can you show us a more complete example that runs both hooks? I didn't
see in that issue where it was clear that both were being run. When I
try to make a minimal example, like this:

-- >8 --
git init -q repo
cd repo

echo 'echo >&2 running in-repo hook' >.git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
git commit --allow-empty -m "should have run in-repo hook"

git config core.hookspath $PWD
git commit --allow-empty -m "should have run no hook"

echo 'echo >&2 running external hook' >pre-commit
chmod +x pre-commit
git commit --allow-empty -m "should have run external hook"
-- >8 --

I get the expected output:

  running in-repo hook
  [main (root-commit) 22a8fd5] should have run in-repo hook
  [main ebc5524] should have run no hook
  running external hook
  [main 5ca6b75] should have run external hook

Looking at the code, everything is as I'd expect. Certainly there could
be a bug where it finds the wrong path, but I don't see how it could
ever run _two_ hooks.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux