zed-industries/zed · error · anyhow::Error
git metadata path escapes its filesystem root: {path:?}
Error message
git metadata path escapes its filesystem root: {path:?} What it means
normalize_git_metadata_path rejected a git metadata path: lexically normalizing the path (e.g. the gitdir pointer read from a linked worktree's .git file) produced a result that escapes the filesystem root via '..' components. A malicious or corrupt .git file pointing outside the root triggers this security guard in Repository::new.
Source
Thrown at crates/git/src/repository.rs:95
} else {
None
}
}
fn linked_worktree_git_dir(worktree_path: &Path) -> Result<PathBuf> {
let dot_git_path = worktree_path.join(".git");
let git_file = std::fs::read_to_string(&dot_git_path)
.with_context(|| format!("failed to read {}", dot_git_path.display()))?;
let git_dir = git_file
.strip_prefix("gitdir:")
.context("worktree .git file missing gitdir pointer")?
.trim();
Ok(worktree_path.join(git_dir))
}
fn normalize_git_metadata_path(path: PathBuf) -> Result<PathBuf> {
paths::normalize_lexically(&path)
.map_err(|_| anyhow!("git metadata path escapes its filesystem root: {path:?}"))
}
/// Commit data needed for the git graph visualization.
#[derive(Debug, Clone)]
pub struct CommitData {
pub sha: Oid,
/// Most commits have a single parent, so we use a SmallVec to avoid allocations.
pub parents: SmallVec<[Oid; 1]>,
pub author_name: SharedString,
pub author_email: SharedString,
pub commit_timestamp: i64,
pub subject: SharedString,
pub message: SharedString,
}
#[derive(Debug)]
pub struct InitialGraphCommitData {
pub sha: Oid,View on GitHub (pinned to 5a9b9558db)
Solutions
- Inspect the worktree's .git file 'gitdir:' pointer — it must reference a path inside the git metadata root
- Re-create the linked worktree with a healthy 'git worktree add' if the pointer is corrupt
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/git/src/repository.rs:95 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20).
Data as JSON: /api/errors/bd69d4a98b4b9b7d.
Report an issue: GitHub.