pub fn install_commit_msg(repo_root: &Path, force: bool) -> Result<PathBuf>Expand description
Install commit-msg for the repository rooted at repo_root. The
effective target directory is resolved as follows:
- Open the repository via
git2::Repository::discoverso a linked worktree’s.gitfile pointer is followed transparently. - If
core.hooksPathis set in the repo config (the project’s recommended setup iscore.hooksPath = .githooks), resolve it against the workdir and install there. The directory is created if missing. - Otherwise fall back to
<gitdir>/hooks/(where<gitdir>is the worktree’s admin dir — e.g.<main>/.git/worktrees/<name>/for a linked worktree, or<root>/.git/for the main worktree).
Returns the written path on success. When force is false
(default) and the target file already exists, returns
GwmError::Other("commit-msg hook already exists at … — pass --force to overwrite") without touching the file. Bare repos and
non-git dirs are rejected with an error; the goal is “fail
loudly, leak nothing into the filesystem”.