Skip to main content

encode_ofs_distance

Function encode_ofs_distance 

Source
pub fn encode_ofs_distance(out: &mut Vec<u8>, distance: u64)
Expand description

Encode an OFS_DELTA backwards distance — the inverse of [ofs_distance].

Not the same varint as the one above, and that is the whole reason this is written out rather than shared: each continuation subtracts one before shifting, so the encoding has no redundant representations. Getting this wrong by one produces a pack git index-pack --strict rejects — or worse, one it accepts and mis-reads, because a delta would then be applied against the wrong base.

The distance is emitted most-significant group first, which is why it is built backwards into a scratch buffer.