Skip to main content

main_repo_root

Function main_repo_root 

Source
pub async fn main_repo_root(repo_path: PathBuf) -> Result<PathBuf, GitError>
Expand description

Re-exported repository metadata APIs. Resolves the main repository root for a repository or linked worktree.

Uses git rev-parse --git-dir --git-common-dir, normalizes both paths to absolute form, detects whether repo_path is a linked worktree (git-dir differs from git-common-dir), and then returns the shared repository root.

§Arguments

  • repo_path - Path to a git repository or worktree

§Returns

Ok(path) containing the main repository root, Err(GitError) on failure.

§Errors

Returns an error if git metadata cannot be queried from repo_path.