pub fn install_git_hooks(
worktree: &Path,
broker_url: &str,
agent_id: &str,
expected_branch: &str,
strict_branch_guard: bool,
) -> Result<(), PawError>Expand description
Installs git-paw’s post-commit dispatcher and pre-push block hook.
Linked git worktrees share the main repository’s .git/hooks/ directory
(unless extensions.worktreeConfig is enabled, which is intrusive). This
function therefore:
- Resolves the common git dir via
git rev-parse --git-common-dirand installs the dispatcher hooks at<common>/hooks/post-commitand<common>/hooks/pre-push(chained onto any existing hooks). - Resolves the linked git dir via
git rev-parse --git-dirand writes a per-worktree marker file at<linked>/paw-agent-idcontaining thePAW_AGENT_IDandPAW_BROKER_URLvalues the dispatcher will source.
The dispatcher hook reads $GIT_DIR/paw-agent-id at commit time — git sets
GIT_DIR to the correct per-worktree gitdir, so each worktree publishes
under its own agent id.