# Inaccurate documentation for core.hooksPath?

2 messages from 2024-05-23 to 2024-05-29. Participants: Mark Boyd - Q2AAAA, Jeff King.
Thread: https://gitlist.dev/t/61538

## Mark Boyd - Q2AAAA, 2024-05-23 19:36

Subject: Inaccurate documentation for core.hooksPath?
Message-ID: <CABBKgan9hLme+9WTNNVrZXxqO4-VRGiC3RLQgfKFUHAy3QZvDA@mail.gmail.com>
URL: https://gitlist.dev/e/CABBKgan9hLme%2B9WTNNVrZXxqO4-VRGiC3RLQgfKFUHAy3QZvDA%40mail.gmail.com

```
Hello,

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?

Thanks,
Mark

```

## Jeff King, 2024-05-29 10:45

Subject: Re: Inaccurate documentation for core.hooksPath?
Message-ID: <20240529104515.GG1098944@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20240529104515.GG1098944%40coredump.intra.peff.net
In-Reply-To: <CABBKgan9hLme+9WTNNVrZXxqO4-VRGiC3RLQgfKFUHAy3QZvDA@mail.gmail.com>

```
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

```
