pub fn get_worktree_root(cwd: &Path) -> Option<String>Expand description
Get the worktree root path if the current directory is within a git worktree.
Returns the absolute path to the worktree root (the directory containing
the .git file that points to the worktree’s git directory).
Returns None if:
- The directory is not in a git repository
- The directory is in a normal git repository (not a worktree)
§Example
ⓘ
use std::path::Path;
use mi6_core::context::get_worktree_root;
// In a worktree: returns "/path/to/worktree"
let root = get_worktree_root(Path::new("/path/to/worktree/subdir"));
// In a normal repo: returns None
let root = get_worktree_root(Path::new("/path/to/normal/repo"));