Skip to main content

get_worktree_root

Function get_worktree_root 

Source
pub fn get_worktree_root() -> Result<Option<PathBuf>>
Expand description

Get the worktree root for the current directory.

If the current directory is inside a linked worktree (not the main repo), returns the root path of that worktree. Returns None if in the main repo.

ยงReturns

  • Ok(Some(path)) - The worktree root if in a linked worktree
  • Ok(None) - If in the main repository (not a linked worktree)
  • Err - If not in a git repository