GitoxideLabs/gitoxide · error · anyhow::Error

(re-raised mailmap error via bail!(err))

Error message

{err} (re-raised mailmap error via bail!(err))

What it means

While running `gix mailmap check`, the call to `repo.open_mailmap_into(&mut mailmap)` failed and the error is re-raised verbatim via `bail!(err)`. The parenthetical in the message is an annotation; the actual content is the underlying mailmap-open error (parse or IO failure while loading .mailmap files from the repository).

Solutions

  1. Inspect the underlying error text for the real cause and fix the `.mailmap` file syntax
  2. Check file permissions on `.mailmap`
  3. Temporarily rename/remove `.mailmap` to confirm it is the source
  4. Use `git check-mailmap` to cross-validate mailmap entries

Example fix

# before (.mailmap)
Proper Name <proper@email> <bad>
# after
Proper Name <proper@email> <commit@email>
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-validate: ensure .mailmap exists and is readable where expected
if repo_dir.join(".mailmap").is_file() && std::fs::metadata(repo_dir.join(".mailmap")).is_err() {
    eprintln!(".mailmap unreadable");
}

Try / catch

match result {
    Err(e) if e.to_string().contains("mailmap") => {
        eprintln!("mailmap load failed: {e}; check .mailmap syntax/permissions");
    }
    other => other?,
}

Prevention

When it happens

Trigger: `repo.open_mailmap_into()` returns Err — typically because a `.mailmap` file (repository or worktree level) is unreadable or malformed — and the check function forwards that error.

Common situations: A malformed `.mailmap` entry in the repo; permission problems reading `.mailmap`; running in an environment where the mailmap file cannot be opened (e.g. bare repo with unexpected mailmap config).

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 GitoxideLabs/gitoxide@e73179060b (2026-09-08). Data as JSON: /api/errors/bde9b98a6e308d51. Report an issue: GitHub.

Appendix: source

Thrown at gitoxide-core/src/repository/mailmap.rs:69

}

pub fn check(
    repo: gix::Repository,
    format: OutputFormat,
    contacts: Vec<BString>,
    mut out: impl io::Write,
    mut err: impl io::Write,
) -> anyhow::Result<()> {
    if format != OutputFormat::Human {
        bail!("Only human output is supported right now");
    }
    if contacts.is_empty() {
        bail!("specify at least one contact to run through the mailmap")
    }

    let mut mailmap = gix::mailmap::Snapshot::default();
    if let Err(err) = repo.open_mailmap_into(&mut mailmap) {
        bail!(err);
    }

    let mut buf = Vec::new();
    for contact in contacts {
        let actor = match gix::actor::IdentityRef::from_bytes(&contact) {
            Ok(a) => a,
            Err(_) => {
                let Some(email) = contact
                    .trim_start()
                    .strip_prefix(b"<")
                    .and_then(|rest| rest.trim_end().strip_suffix(b">"))
                else {
                    writeln!(err, "Failed to parse contact '{contact}' - skipping")?;
                    continue;
                };
                gix::actor::IdentityRef {
                    name: "".into(),
                    email: email.into(),

View on GitHub (pinned to e73179060b)