JanDeDobbeleer/oh-my-posh · error
gitstatus: delta target size mismatch
Error message
gitstatus: delta target size mismatch
What it means
After applying all delta opcodes, applyDelta compares the reconstructed buffer length with the target size decoded from the delta header. A mismatch means the opcode stream did not reproduce exactly targetSize bytes - the delta is corrupt, incomplete, or was misparsed.
Source
Thrown at src/gitstatus/objectstore.go:463
}
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) {
return 0, 0
}
b := data[n]
n++
v |= int64(b&0x7f) << shift
if b&0x80 == 0 {
return v, nView on GitHub (pinned to 0976794618)
Solutions
- Re-download/re-clone to replace the corrupted packfile
- Re-check opcode decode loop: ensure copy opcodes consume size+offset varints and inserts advance delta by exactly op bytes
- Assert targetSize > 0 and base size matches the delta's declared base before applying
- Validate pack checksum (SHA-1 trailer) before delta application to fail early with a clearer error
Example fix
// before
result, err := applyDelta(base, delta, targetSize)
// after
if int64(len(base)) == 0 && targetSize > 0 { return nil, errors.New("empty base for delta") }
result, err := applyDelta(base, delta, targetSize) Defensive patterns
Strategy: validation
Validate before calling
if int64(len(base)) == 0 && targetSize > 0 {
return nil, errors.New("empty base for non-empty delta target")
} Type guard
func deltaApplicable(baseLen, targetSize int64) bool {
return targetSize == 0 || baseLen > 0
} Prevention
- Verify the pack SHA-1 trailer before trusting entries
- Add an assertion test that applyDelta round-trips known git deltas
- Log delta header sizes alongside result length to speed up misalignment debugging
When it happens
Trigger: applyPackDelta feeds applyDelta a delta whose opcodes produce fewer or more bytes than the header's target size, typically because the delta stream is truncated/corrupt or opcode length fields were decoded incorrectly (e.g. copy-size varint misread).
Common situations: Corrupted packfiles after a failed network transfer; writing a custom pack reader with wrong varint endianness for copy offset/size fields; partial reads when streaming packs from disk or network.
Related errors
- gitstatus: truncated delta insert
- 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/8f75b3eecaafd05b.
Report an issue: GitHub.