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

'git for-each-ref' failed with error {:?}

Error message

'git for-each-ref' failed with error {:?}

What it means

The 'git for-each-ref refs/tags' subprocess launched successfully but exited with a non-zero status ({error} is the process Output). The repository state, a corrupt refs directory, or a git version issue made tag enumeration fail; the ensure! guard relays the raw output as the failure detail for the tag-names lookup.

Source

Thrown at crates/git/src/commit.rs:99

pub(crate) async fn get_tag_names(
    git: &GitBinary,
    shas: &[Oid],
) -> Result<HashMap<Oid, Vec<String>>> {
    if shas.is_empty() {
        return Ok(HashMap::default());
    }

    let output = git
        .build_command(&[
            "for-each-ref",
            "refs/tags",
            "--sort=-creatordate",
            "--format=%(objectname)%00%(*objectname)%00%(refname:short)",
        ])
        .output()
        .await
        .context("starting git for-each-ref process")?;
    anyhow::ensure!(
        output.status.success(),
        "'git for-each-ref' failed with error {:?}",
        String::from_utf8_lossy(&output.stderr)
    );

    Ok(parse_tag_names(
        &String::from_utf8_lossy(&output.stdout),
        shas,
    ))
}

fn parse_tag_names(output: &str, shas: &[Oid]) -> HashMap<Oid, Vec<String>> {
    let shas = shas.iter().copied().collect::<HashSet<_>>();
    let mut result = HashMap::<Oid, Vec<String>>::default();

    for line in output.lines() {
        let mut fields = line.split('\0');
        let object_sha = fields.next();

View on GitHub (pinned to f4178619ac)

Solutions

  1. Run 'git for-each-ref refs/tags' manually in the repo to see the underlying git error
  2. Check for corrupted refs under .git/refs/tags or a damaged packed-refs file
  3. Propagate with the process's stderr captured so users see git's own diagnosis
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/git/src/commit.rs:99 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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