Skip to main content

Module pack

Module pack 

Source
Expand description

Packfile reading (pack v2 + index v2), the normal post-gc/clone storage.

A .idx (version 2) maps object hashes to byte offsets in the sibling .pack; each pack object is a varint-headed, zlib-compressed blob that may be whole (commit/tree/blob/tag) or a delta (OFS_DELTA/REF_DELTA) against another object. This module resolves deltas recursively and verifies the SHA-1 of every reconstructed object.

Reference: git Documentation/gitformat-pack.txt (pack + index v2 layouts, delta instruction encoding).

Functions§

apply_delta
Apply a git delta (base + delta instructions → reconstructed object).
list_packed
Enumerate every object SHA across all packfiles under objects_dir.
read_packed
Read hash from any packfile under objects_dir. Returns Ok(None) when no pack contains it (so the caller can report a genuine not-found).