zed-industries/zed · error · anyhow::Error

git show failed: {}

Error message

git show failed: {}

What it means

The 'git show --format= -z --raw' subprocess used to load a commit's diff exited non-zero; the ensure! formats git's own output ({}) into the error. The commit argument is likely unknown to this repository, or the repo/worktree state is broken, so the raw diff for the commit could not be obtained.

Source

Thrown at crates/git/src/repository.rs:1414

            urls.insert(name.to_string(), url.trim_start().to_string());
        }
    }
    urls
}

impl GitRepository for RealGitRepository {
    fn path(&self) -> PathBuf {
        self.git_dir.clone()
    }

    fn main_repository_path(&self) -> PathBuf {
        self.common_dir.clone()
    }

    fn show(&self, commit: String) -> BoxFuture<'_, Result<CommitDetails>> {
        let git = self.git_binary();
        self.executor
            .spawn(async move {
                let output = git
                    .build_command(&[
                        "show",
                        "--no-patch",
                        "--format=%H%x00%B%x00%at%x00%ae%x00%an%x00",
                        &commit,
                        // `commit` reaches here as whatever the user typed, so it can name
                        // a branch that also names a path in the working tree.
                        "--",
                    ])
                    .output()
                    .await?;
                let output = std::str::from_utf8(&output.stdout)?;
                let fields = output.split('\0').collect::<Vec<_>>();
                if fields.len() != 6 {
                    bail!("unexpected git-show output for {commit:?}: {output:?}")
                }
                let sha = fields[0].to_string().into();

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Include the captured stdout/stderr in logs to expose git's diagnosis (bad object, not a git repo)
  2. Validate the commit sha exists before requesting its diff
  3. Retry once for transient worktree/index lock contention
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/git/src/repository.rs:1407 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/564e31e2bf57c805. Report an issue: GitHub.