Skip to main content

Module worktree

Module worktree 

Source
Expand description

Per-run git worktree management.

Every omne run creates a detached-HEAD worktree at .omne/wt/<run_id>/ via git worktree add --detach. Detached HEAD avoids git’s “branch already checked out” refusal on back-to-back runs from the same branch (plan R5).

The module is a thin wrapper over the git binary (subprocess), not libgit2, to stay consistent with the user’s own git installation and hook configuration. The process pattern mirrors crate::github for spawn-and-capture handling, with two local additions:

  • LC_ALL=C is forced on every git invocation so stderr classifier substrings like "not a git repository" stay locale-independent.
  • A GIT_TIMEOUT bounds each subprocess so a wedged git (corrupted index, stalled network filesystem) cannot hang omne run forever.

Path-length preflight: Windows’ default MAX_PATH is 260 characters; worktree creation can fail with cryptic “Filename too long” errors on long volume roots. preflight_volume_path_length warns at 80 chars and errors at 120 before any state mutation happens.

Structs§

WorktreeList
Cross-checked enumeration of per-run worktrees.

Enums§

Error
RemoveMode
Whether remove may discard uncommitted changes in the worktree.

Constants§

GIT_TIMEOUT
Upper bound on any single git worktree subprocess. Enough slack for slow NFS/SMB volumes without letting a wedged git stall the runner.
PATH_LENGTH_ERROR
Volume path length at which preflight fails outright.
PATH_LENGTH_WARN
Volume path length at which a warning is emitted (plan R5 preflight).

Functions§

create
Create a detached-HEAD worktree at .omne/wt/<run_id>.
list
Enumerate per-run worktrees under .omne/wt/, partitioned into healthy pairs plus filesystem-only and git-only orphans.
preflight_volume_path_length
Check volume root path length against the plan’s thresholds.
remove
Remove a per-run worktree via git worktree remove.