zed-industries/zed · error
raw diff is missing the status
Error message
raw diff is missing the status
What it means
The same raw-diff metadata parser bails when, after splitting the ':old_mode new_mode old_oid new_oid status' metadata on whitespace, there is no fifth field at all — i.e. git produced a metadata record with fewer tokens than the documented format. This is a contract violation between git's output and the parser, not a user-input error.
Source
Thrown at crates/git/src/commit.rs:217
let mut fields = metadata
.strip_prefix(':')
.context("raw diff metadata is missing its ':' prefix")?
.split_ascii_whitespace();
let old_mode = fields.next().context("raw diff is missing the old mode")?;
let new_mode = fields.next().context("raw diff is missing the new mode")?;
let old_oid = fields
.next()
.context("raw diff is missing the old object ID")?;
let new_oid = fields
.next()
.context("raw diff is missing the new object ID")?;
let status = match fields.next() {
Some("M") => StatusCode::Modified,
Some("T") => StatusCode::TypeChanged,
Some("A") => StatusCode::Added,
Some("D") => StatusCode::Deleted,
Some(status) => anyhow::bail!("unsupported raw diff status {status}"),
None => anyhow::bail!("raw diff is missing the status"),
};
Ok(CommitDiffEntry {
path,
status,
old_object: (!old_oid.bytes().all(|byte| byte == b'0')).then(|| CommitDiffObject {
oid: old_oid,
kind: if old_mode == GITLINK_MODE {
CommitDiffObjectKind::Gitlink
} else {
CommitDiffObjectKind::Blob
},
}),
new_object: (!new_oid.bytes().all(|byte| byte == b'0')).then(|| CommitDiffObject {
oid: new_oid,
kind: if new_mode == GITLINK_MODE {
CommitDiffObjectKind::Gitlink
} else {View on GitHub (pinned to f4178619ac)
Solutions
- Reproduce manually with `git diff-tree -r -z --abbrev=64 --no-renames <base> <head>` and inspect the metadata tokens
- Check `git config --get diff.external` and core.pager/wrappers that could rewrite output, and unset them for raw diffs
- Use a stock, current git release in PATH for the app
Defensive patterns
Strategy: validation
Validate before calling
// sanity-check a metadata record before parsing
let token_count = metadata.trim_start_matches(':').split_ascii_whitespace().count();
if token_count != 5 { /* skip/log instead of parse */ } Type guard
fn is_well_formed_raw_metadata(metadata: &str) -> bool {
metadata.strip_prefix(':')
.map(|m| m.split_ascii_whitespace().count() == 5)
.unwrap_or(false)
} Try / catch
Err(e) if e.to_string().contains("raw diff is missing") => { /* log record and continue */ } Prevention
- Run raw-diff parsing only against stock git output; keep diff.external/wrappers unset for these invocations
- Pin a known-good git version in CI and document it as the supported minimum
When it happens
Trigger: A `git diff --raw -z` / `git diff-tree -r -z` metadata record missing its status token — caused by nonstandard git builds, output-mangling filters (external diff drivers writing to stdout), or locale/wrapper tools rewriting git output.
Common situations: Git wrappers or diff.external/diff.driver config polluting raw output, ancient or forked git versions with different --raw formats, or wrappers like hub/gh shims in PATH emitting extra content.
Related errors
- unsupported raw diff status {status}
- unexpected git-show output for {commit:?}: {output:?}
- invalid git oid hex length: expected 1..={SHA1_HEX_LENGTH} f
- 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/511fb9992153002f.
Report an issue: GitHub.