pub fn get_local_git_dir(cwd: &Path) -> Option<String>Expand description
Get the absolute path to the .git directory for a working directory.
Uses direct file system access for speed (~15µs vs ~640µs with libgit2).
Walks up the directory tree to find .git, handling both normal repos
and worktrees.
Returns None if:
- The directory is not a git repository
- Any error occurs
§Example
ⓘ
use std::path::Path;
use mi6_core::context::get_local_git_dir;
// In a normal repo: returns "/path/to/repo/.git"
let git_dir = get_local_git_dir(Path::new("/path/to/repo"));
// In a worktree: returns "/path/to/main/.git/worktrees/branch-name"
let git_dir = get_local_git_dir(Path::new("/path/to/worktree"));