Skip to main content

git_hook_block

Function git_hook_block 

Source
pub fn git_hook_block(shell: &str, store: &StoreRef) -> String
Expand description

The block a git hook runs: one backgrounded, silenced sync.

Backgrounded (( … & ) in a subshell, so no job-control notice reaches the terminal) because a hook must not make git commit wait on a graph refresh, and silenced because a hook that prints — or fails — on a store that is momentarily busy would be noise on every commit. sync exits 3 when another process holds the write lock, and the next commit picks the work up.

shell is the already-quoted command prefix from McpCommand::shell; the store contributes either --auto or its own quoted path, since a path with a space in it would otherwise be word-split into two arguments.

--auto is what makes the block correct in a git worktree. Git runs a hook with the working tree it acted on as the working directory, so sync walks up from there to that tree’s own root and updates that tree’s own store — the same block, committed once, doing the right thing in every checkout of the repository.