Skip to main content

find_worktree

Function find_worktree 

Source
pub fn find_worktree(
    repo: &Repository,
    name: &str,
) -> Result<WorktreeDescriptor>
Expand description

Find a worktree by its admin name, its branch name, or its root-relative path.

The admin name is a creation-time artifact (see encode_worktree_name) and can go stale if a worktree is moved outside move_worktree (e.g. a raw git worktree move); the root-relative path never does, since git rewrites gitdir on every move. Nothing here decodes an admin name back into a path — a stale name is a label, not a key.

Returns WorktreeError::NotFound if no matching worktree exists.