zed-industries/zed · error

git log command failed with {}: {}

Error message

git log command failed with {}: {}

What it means

Error from `initial_graph_data` when the streaming `git log` process that populates the initial commit graph exits non-zero. The first placeholder is the process exit status; the second is the collected stderr. When stderr is empty, a variant without the stderr portion is emitted instead. Typically indicates an invalid log source revision range or a broken repository.

Source

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

                    }
                }

                return Ok(());
            }

            if git_binary.is_trusted {
                let git_binary = git_binary.envs(HashMap::clone(&env));
                git_binary
                    .run(&["hook", "run", "--ignore-missing", hook.as_str()])
                    .await?;
            }
            Ok(())
        }
        .boxed()
    }

    fn initial_graph_data(
        &self,
        log_source: LogSource,
        log_order: LogOrder,
        request_tx: Sender<Vec<Arc<InitialGraphCommitData>>>,
    ) -> BoxFuture<'_, Result<()>> {
        let git = self.git_binary();

        async move {
            let log_source_args = log_source.get_args();
            let mut git_log_command = vec!["log", GRAPH_COMMIT_FORMAT, log_order.as_arg()];
            git_log_command.extend(log_source_args.iter().map(|arg| arg.as_ref()));
            let mut command = git.build_command(&git_log_command);
            command.stdout(Stdio::piped());
            command.stderr(Stdio::piped());

            let mut child = command.spawn()?;
            let stdout = child.stdout.take().context("failed to get stdout")?;
            let stderr = child.stderr.take().context("failed to get stderr")?;
            let mut reader = BufReader::new(stdout);

View on GitHub (pinned to 5a9b9558db)

Solutions

  1. Read the stderr portion of the message and act on it directly.
  2. Treat `does not have any commits yet` as empty history, not as a hard error.
  3. If stderr says `bad object`, repair or re-clone; for shallow clones consider `git fetch --unshallow`.
  4. Validate user-supplied revisions and path filters before starting the log stream.
Defensive patterns

Strategy: try-catch

Validate before calling

// unborn HEAD has no history
if git.run(&["rev-parse", "--verify", "--quiet", "HEAD"]).await.is_err() {
    return Ok(Vec::new());
}

Try / catch

match log_result {
    Err(e) if e.to_string().contains("does not have any commits yet") => {
        Ok(Vec::new()) // unborn branch: empty history
    }
    Err(e) if e.to_string().contains("bad object") => {
        // corrupt/shallow store: suggest fetch --unshallow or re-clone
        Err(e)
    }
    other => other?,
}

Prevention

When it happens

Trigger: `fatal: your current branch ... does not have any commits yet` on an unborn HEAD; `fatal: bad object` from a corrupt or shallow object store; invalid revision arguments; permission errors reading objects; repository mid-repack or mid-rebase manipulation.

Common situations: Requesting history for a brand-new branch with zero commits; partial/shallow clones missing objects; interrupted clones; custom log filters referencing paths or refs that do not exist.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20). Data as JSON: /api/errors/dbd9d0747725bc3b. Report an issue: GitHub.