pub enum RepoHooks {
Own(PathBuf),
Redirected {
to: PathBuf,
own: PathBuf,
},
Nowhere,
}Expand description
Where git dispatches hooks from, and whether that is this repository’s OWN
hooks directory or somewhere core.hooksPath sent it.
This replaces a bare repo_hooks_dir() that returned only the dispatch path.
--git-path hooks is still the right question — never --git-dir plus
join("hooks"), because hooks are explicitly SHARED across worktrees while a
linked worktree’s --git-dir is its own PRIVATE gitdir, so joining “hooks”
onto it names a directory git never dispatches from. The addition is asking
--git-common-dir alongside it, so the answer can be compared against the
directory that would be ours.
The distinction did not exist and its absence was silent. --git-path hooks
honours core.hooksPath, so in a repository running husky it answers
.husky/_ — inside the repo, plausible, and wrong. install wrote four
shims there, husky’s own prepare regenerated the directory on the next
npm install, and the repository went back to having no checks with nothing
to show for it. Every guarantee this tool makes was off in those repositories
and the fleet reported them as merely “drifted”.
Variants§
Own(PathBuf)
<git-common-dir>/hooks. Git dispatches from here and it is ours to write.
Redirected
core.hooksPath points somewhere else. Another tool owns dispatch here,
and writing to own would install shims git never runs.
Nowhere
Not in a repository, or git would not answer.