JanDeDobbeleer/oh-my-posh · error
gitstatus: truncated delta insert
Error message
gitstatus: truncated delta insert
What it means
applyDelta applies a git packfile delta (copy/insert opcodes) to a base object to reconstruct an object. An insert opcode's low 7 bits encode the literal byte count to copy from the delta stream. This error means the delta stream ended before that many bytes were available, so the pack data is corrupt or the parser is misaligned.
Source
Thrown at src/gitstatus/objectstore.go:456
}
}
if size == 0 {
size = 0x10000
}
if offset+size > int64(len(base)) {
return nil, errors.New("gitstatus: delta copy out of range")
}
result = append(result, base[offset:offset+size]...)
continue
}
if op == 0 {
return nil, errors.New("gitstatus: invalid delta opcode")
}
// insert literal of length op
if int(op) > len(delta) {
return nil, errors.New("gitstatus: truncated delta insert")
}
result = append(result, delta[:op]...)
delta = delta[op:]
}
if int64(len(result)) != targetSize {
return nil, errors.New("gitstatus: delta target size mismatch")
}
return result, nil
}
// decodeSizeVarint reads git's little-endian size varint (used in delta
// headers), distinct from the big-endian offset varint.
func decodeSizeVarint(data []byte) (v int64, n int) {
shift := uint(0)
for {
if n >= len(data) {View on GitHub (pinned to 0976794618)
Solutions
- Re-fetch or re-clone the repository to obtain an intact packfile
- Verify the delta stream parsing: confirm decodeSizeVarint consumed exactly the varint bytes before opcode parsing starts
- Validate the pack entry's expected data length against bytes actually read before calling applyDelta
- Log the remaining delta length vs op length at failure to find where the stream went misaligned
Example fix
// before: trusting declared sizes blindly
result, err := applyDelta(base, delta)
// after: sanity-check delta length against target size first
if int64(len(delta)) < 2 { return nil, errors.New("delta too short") }
result, err := applyDelta(base, delta) Defensive patterns
Strategy: validation
Validate before calling
if int64(len(delta)) == 0 || targetSize <= 0 {
return nil, errors.New("delta header invalid, refusing to apply")
} Type guard
func deltaLooksSane(delta []byte, targetSize int64) bool {
return len(delta) > 0 && targetSize > 0 && int64(len(delta)) >= 2
} Prevention
- Always validate pack checksums before delta application
- Test the pack parser against truncated packfiles in CI
- Reuse the existing varint decoder instead of hand-rolling offset math
When it happens
Trigger: Calling applyPackDelta on a pack entry whose delta data is truncated (incomplete pack read, corrupt .pack/.idx, or a parsing bug that consumed the wrong number of bytes for the size varints, leaving the opcode stream misaligned).
Common situations: Interrupted git fetch/clone leaving a partial packfile; disk corruption; manually reading packfiles with an off-by-one in srcSize/targetSize varint decoding so insert lengths are read from wrong offsets.
Related errors
- gitstatus: delta target size mismatch
- font %v has no name table
- gitstatus: reftables HEAD requires exec fallback
- gitstatus: staged adds and deletes may be renames, deferring
- unclosed section:
AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31).
Data as JSON: /api/errors/49dfb2f2efdaa5d9.
Report an issue: GitHub.