zed-industries/zed · error

Invalid unmerged status code: {byte}

Error message

Invalid unmerged status code: {byte}

What it means

For unmerged (conflicted) entries, the Y code of the XY pair is parsed by UnmergedStatusCode::from_byte, which accepts only A, D and U. Valid conflict pairs (UU, AA, DD, AU, UA, DU, UD) are handled earlier; this error fires only when git emits an unmerged pair whose second byte is outside that set.

Source

Thrown at crates/git/src/status.rs:280

            worktree_status: StatusCode::Unmodified,
        })
    }

    pub fn worktree(self) -> FileStatus {
        FileStatus::Tracked(TrackedStatus {
            index_status: StatusCode::Unmodified,
            worktree_status: self,
        })
    }
}

impl UnmergedStatusCode {
    fn from_byte(byte: u8) -> anyhow::Result<Self> {
        match byte {
            b'A' => Ok(UnmergedStatusCode::Added),
            b'D' => Ok(UnmergedStatusCode::Deleted),
            b'U' => Ok(UnmergedStatusCode::Updated),
            _ => anyhow::bail!("Invalid unmerged status code: {byte}"),
        }
    }
}

#[derive(Clone, Debug, Default, Copy, PartialEq, Eq)]
pub struct TrackedSummary {
    pub added: usize,
    pub modified: usize,
    pub deleted: usize,
}

impl TrackedSummary {
    pub const UNCHANGED: Self = Self {
        added: 0,
        modified: 0,
        deleted: 0,
    };

View on GitHub (pinned to f4178619ac)

Solutions

  1. Run the exact status command during a conflict and inspect the XY bytes of unmerged lines.
  2. Eliminate any wrapper/alias/env that rewrites `git status` stdout.
  3. Keep capture flags and parser in sync (`--porcelain=v1 -z`).
  4. Report upstream if a stock git emits an unmerged Y code outside A/D/U.
Defensive patterns

Strategy: try-catch

Try / catch

match stdout.parse::<GitStatus>() {
    Err(e) if e.to_string().contains("Invalid unmerged status code") => {
        // capture raw output during the conflict; verify no wrapper rewrote it
    }
    other => other?,
}

Prevention

When it happens

Trigger: Repository is mid-merge/rebase/cherry-pick (so unmerged entries exist) and the status output contains an unexpected second byte in an unmerged pair — from a wrapper rewriting status output, misaligned line parsing, or a nonstandard git build.

Common situations: Parsing status captured during conflicts with modified tooling; git wrappers in CI that reformat output; mismatches between the flags used to capture output and the parser's assumptions.

Related errors


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