astrid-runtime/astrid · error

git could not enumerate the captured version chain

Error message

git could not enumerate the captured version chain

What it means

`version_chain_from_git` runs `git rev-list --reverse --max-count=32 HEAD -- <path>` to enumerate the file's captured version chain. If the git subprocess exits with a non-zero status, the crate bails with this error since it cannot enumerate the chain.

Source

Thrown at crates/astrid-storage-chunker-evidence/src/corpus.rs:95

    pub fn version_chain_from_path(name: String, root: &Path) -> Result<Self> {
        Self::from_files(name, CorpusKind::VersionChain, collect_files(root, false)?)
    }

    pub fn version_chain_from_git(
        name: String,
        repository: &Path,
        relative_path: &Path,
    ) -> Result<Self> {
        validate_relative_git_path(relative_path)?;
        let revisions = Command::new("git")
            .args(["-C"])
            .arg(repository)
            .args(["rev-list", "--reverse", "--max-count=32", "HEAD", "--"])
            .arg(relative_path)
            .output()
            .context("enumerate captured version chain")?;
        if !revisions.status.success() {
            bail!("git could not enumerate the captured version chain");
        }
        let revisions = String::from_utf8(revisions.stdout).context("git emitted non-UTF-8 IDs")?;
        let mut inputs = Vec::new();
        for revision in revisions.lines() {
            if revision.is_empty() || !revision.bytes().all(|byte| byte.is_ascii_hexdigit()) {
                bail!("git emitted an invalid revision ID");
            }
            if !git_path_exists_at_revision(repository, relative_path, revision)? {
                continue;
            }
            let object = format!("{revision}:{}", relative_path.to_string_lossy());
            let version = Command::new("git")
                .args(["-C"])
                .arg(repository)
                .args(["show", &object])
                .output()
                .context("read captured version")?;
            if !version.status.success() {

View on GitHub (pinned to affd8760f4)

Solutions

  1. Run `git rev-list --reverse --max-count=32 HEAD -- <path>` manually in the repo to see the underlying error.
  2. Verify the path is tracked and has commits reachable from HEAD.
  3. Confirm you are in a valid, non-corrupt git worktree with a resolvable HEAD.
  4. Check that git is installed and on PATH.
Defensive patterns

Strategy: validation

Validate before calling

use std::process::Command;
let ok = Command::new("git").arg("-C").arg(&repo).args(["rev-parse", "--is-inside-work-tree"])
    .output().map(|o| o.status.success()).unwrap_or(false);
assert!(ok, "not a valid git worktree");

Try / catch

match version_chain_from_git(&repo, &path, name) {
    Ok(corpus) => corpus,
    Err(e) if e.to_string().contains("enumerate captured version chain") => {
        // surface git stderr / run git rev-list manually to diagnose
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling `version_chain_from_git` against a repository where the `git rev-list` subprocess fails: corrupt repo, missing HEAD, bad relative_path, or git not installed producing an error exit.

Common situations: Running the corpus builder outside a valid git worktree; path not tracked on HEAD; shallow/bare repo oddities; corrupted repository metadata.

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 astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/ae7cb7c3e60b83a6. Report an issue: GitHub.