Skip to main content

Module worktree

Module worktree 

Source

Structs§

AttachedSession
CreateResult
Options
PaneEntry
WorktreeEntry

Enums§

RemoveDecision
Decision returned by the remove preflight. CLI layer is responsible for applying it (printing messages, killing sessions, invoking git).

Functions§

create
Run the full worktree-creation flow: resolve the source repo, compute the sibling path, run git worktree add, and execute the matching post-create script. The caller (CLI layer) is responsible for any tmux integration.
list_entries
match_attached
Returns offenders (sessions whose any pane is inside worktree), de-duplicated by session id, in first-seen order.
parse_pane_lines
Parse tmux list-panes output formatted as #{session_id}\t#{session_name}\t#{pane_current_path}.
parse_porcelain
Parse git worktree list --porcelain output. The first worktree block is always the main worktree per git’s documented contract.
remove
Run git worktree remove [--force] <path>. Surfaces git’s stderr verbatim.
remove_decision
render_naming
resolve_repo_root
resolve_target
Find the unique non-main entry matching target (exact path or short branch).
resolve_target_any
Same matching rules as resolve_target but includes the main worktree. Used by read-only commands like worktree list where the main worktree is a valid target.
sessions_attached_to
Shell out to tmux. Returns Err on command failure so caller can apply fail-open / fail-closed policy based on $TMUX.
short_branch
Short branch name from refs/heads/foo → foo. Returns the original if it doesn’t carry the prefix.