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
- Run the exact status command during a conflict and inspect the XY bytes of unmerged lines.
- Eliminate any wrapper/alias/env that rewrites `git status` stdout.
- Keep capture flags and parser in sync (`--porcelain=v1 -z`).
- 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
- During merges/rebases, ensure nothing reformats `git status` stdout (aliases, pagers, CI wrappers).
- Keep capture flags in sync with the parser (--porcelain=v1 -z).
- Report genuinely new unmerged codes upstream with the raw line.
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
- Invalid status code: {byte}
- invalid cat-file header: {header_line}
- git status failed: {stderr}
- grammar directory '{}' already exists, but is not a git clon
- failed to run `git init` in directory '{}'
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/ea8ee954e6f7351e.
Report an issue: GitHub.