zed-industries/zed · error
git log failed in {} with status {}: {}
Error message
git log failed in {} with status {}: {} What it means
Bailed when `git log -5000 --pretty=... --name-only` executed in the worktree directory exits non-zero; the status and stderr are embedded. The git-log context builder mines co-occurrence of file paths across the last 5000 commits, so this fails before the related-files index can be built.
Source
Thrown at crates/edit_prediction_context/src/git_log_context.rs:94
}
}
pub async fn build_git_log_index(worktree_dir: &Path) -> Result<GitLogIndex> {
let mut index = GitLogIndex::new();
let output = new_command("git")
.arg("log")
.arg("-5000")
.arg("--pretty=tformat:@@COMMIT %H")
.arg("--name-only")
.current_dir(worktree_dir)
.output()
.await
.with_context(|| format!("failed to run git log in {}", worktree_dir.display()))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
bail!(
"git log failed in {} with status {}: {}",
worktree_dir.display(),
output.status,
stderr.trim()
);
}
let log = String::from_utf8(output.stdout).context("git log output was not valid UTF-8")?;
let parsed = parse_git_log(&log);
for files in parsed {
for i in 0..files.len() {
for j in (i + 1)..files.len() {
index.add_related(files[i].clone(), files[j].clone());
}
}
}
Ok(index)View on GitHub (pinned to f4178619ac)
Solutions
- Run `git -C <dir> log -5000 --name-only` by hand to reproduce the git failure
- Add the path to safe.directory if git reports dubious ownership
- Verify the directory is a git repo (`git -C <dir> rev-parse --is-inside-work-tree`) before requesting git-log context
- Confirm git is on PATH for the process launching the helper binary
Defensive patterns
Strategy: validation
Validate before calling
let ok = std::process::Command::new("git")
.args(["-C", worktree.to_str().unwrap(), "rev-parse", "--is-inside-work-tree"])
.output()
.map(|o| o.status.success())
.unwrap_or(false);
if !ok { /* skip git-log context for this worktree instead of failing */ } Try / catch
Catch the bail, log the git status/stderr from the message, and fall back to running without the git-log related-files index.
Prevention
- Pre-check that the worktree resolves as a git repo
- Add CI-owned repo paths to safe.directory
- Pin the git binary via env when spawning helpers from editors with minimal PATH
When it happens
Trigger: worktree_dir is not a git repository; 'detected dubious ownership' rejection; broken object database after an interrupted operation; git missing from the helper's PATH when spawned from the editor.
Common situations: Running the context provider on non-git folders; containerized/CI environments with mismatched repo ownership; shallow clones with damaged refs.
Related errors
- git ls-files failed in {} with status {}: {}
- git merge-base --is-ancestor failed
- too many arguments
- git status failed: {stderr}
- git diff-tree failed: {stderr}
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/ea059c800e07e0bb.
Report an issue: GitHub.