{"thread":{"id":"61538","subject":"Inaccurate documentation for core.hooksPath?","startedAt":"2024-05-23T19:37:02Z","lastAt":"2024-05-29T10:45:17Z","messageCount":2,"participants":["Mark Boyd - Q2AAAA","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"495448","messageId":"CABBKgan9hLme+9WTNNVrZXxqO4-VRGiC3RLQgfKFUHAy3QZvDA@mail.gmail.com","threadId":"61538","inReplyTo":null,"subject":"Inaccurate documentation for core.hooksPath?","fromName":"Mark Boyd - Q2AAAA","fromEmail":"mark.boyd@gsa.gov","sentAt":"2024-05-23T19:36:49Z","receivedAt":"2024-05-23T19:37:02Z","isPatch":false,"sender":{"key":"mark.boyd@gsa.gov","avatar":null},"body":"Hello,\n\nThis documentation says that git only looks for hooks in the\nconfigured core.hooksPath:\nhttps://github.com/git/git/blob/master/Documentation/config/core.txt#L499-L504\n\nHowever, in my testing, git will run both hooks located in the\ncore.hooksPath directory and in the local git repo hooks directory\n(.git/hooks by default). Observation of this behavior is documented in\nhttps://github.com/cloud-gov/caulking/issues/37.\n\nIs the behavior I'm seeing the actually expected behavior of git? Or\nare we somehow relying on an edge-case or buggy behavior?\n\nThanks,\nMark\n"},{"id":"495810","messageId":"20240529104515.GG1098944@coredump.intra.peff.net","threadId":"61538","inReplyTo":"CABBKgan9hLme+9WTNNVrZXxqO4-VRGiC3RLQgfKFUHAy3QZvDA@mail.gmail.com","subject":"Re: Inaccurate documentation for core.hooksPath?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-05-29T10:45:15Z","receivedAt":"2024-05-29T10:45:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, May 23, 2024 at 03:36:49PM -0400, Mark Boyd - Q2AAAA wrote:\n\n> This documentation says that git only looks for hooks in the\n> configured core.hooksPath:\n> https://github.com/git/git/blob/master/Documentation/config/core.txt#L499-L504\n> \n> However, in my testing, git will run both hooks located in the\n> core.hooksPath directory and in the local git repo hooks directory\n> (.git/hooks by default). Observation of this behavior is documented in\n> https://github.com/cloud-gov/caulking/issues/37.\n> \n> Is the behavior I'm seeing the actually expected behavior of git? Or\n> are we somehow relying on an edge-case or buggy behavior?\n\nCan you show us a more complete example that runs both hooks? I didn't\nsee in that issue where it was clear that both were being run. When I\ntry to make a minimal example, like this:\n\n-- >8 --\ngit init -q repo\ncd repo\n\necho 'echo >&2 running in-repo hook' >.git/hooks/pre-commit\nchmod +x .git/hooks/pre-commit\ngit commit --allow-empty -m \"should have run in-repo hook\"\n\ngit config core.hookspath $PWD\ngit commit --allow-empty -m \"should have run no hook\"\n\necho 'echo >&2 running external hook' >pre-commit\nchmod +x pre-commit\ngit commit --allow-empty -m \"should have run external hook\"\n-- >8 --\n\nI get the expected output:\n\n  running in-repo hook\n  [main (root-commit) 22a8fd5] should have run in-repo hook\n  [main ebc5524] should have run no hook\n  running external hook\n  [main 5ca6b75] should have run external hook\n\nLooking at the code, everything is as I'd expect. Certainly there could\nbe a bug where it finds the wrong path, but I don't see how it could\never run _two_ hooks.\n\n-Peff\n"}]}