pub fn detect_worktree(cwd: &Path) -> Result<Option<WorktreeInfo>, Error>Expand description
Detect if the given directory is within a git worktree.
Uses the provided cwd path to determine which worktree (if any)
the directory belongs to. This avoids relying on process-global
std::env::current_dir() which is unsafe in multi-threaded tests.
Returns:
Ok(None)if not in a git repo or in the main worktreeOk(Some(WorktreeInfo))if in a secondary worktreeErrif there’s an error running git commands