Skip to main content

acquire_worktree_lock

Function acquire_worktree_lock 

Source
pub fn acquire_worktree_lock(root: &Path) -> Result<RepoLock, u8>
Expand description

Acquire the shared worktree/index lock for the repo rooted at root.

Hold the returned guard across the whole read-modify-write so a second mutating mkit blocks (then times out) instead of racing on the worktree + .mkit/index. On failure, the lock message has already been printed to stderr and the returned u8 is the exit code to propagate.

Mirrors the pattern already used in sparse_checkout and remote_dispatch; new mutating commands should reuse this helper rather than calling repo_lock::acquire_default directly.

ยงErrors

Returns exit::TEMPFAIL when the lock cannot be taken within the default timeout (another mkit holds it, or a stale lockfile is present).