Expand description
Packfiles — git’s compressed, delta-encoded object container.
A packfile (objects/pack/pack-*.pack) stores many objects back-to-back,
each as a small type+size header followed by a zlib stream of either the raw
object content or a delta against another object (by in-pack offset for
OFS_DELTA, or by object id for REF_DELTA). A sibling pack index
(*.idx) maps object ids to their byte offset in the pack so objects can be
found without scanning.
This module provides:
Pack— random access to objects by offset, resolving delta chains (using a caller-supplied resolver forREF_DELTAbases that live outside the pack).PackIndex— parsing and id→offset lookup for the v2.idxformat.PackWriter— serializing objects into a v2 pack and matching.idx.explode_pack— sequentially decoding a received pack (no index needed) into fully-resolved objects, the ingest path for clone/fetch/push.delta— the delta instruction codec.
Delta compression on write (emitting OFS_DELTA/REF_DELTA rather than
one zlib stream per object) is a later optimization; the writer is correct
and self-contained today.
Modules§
- bitmap
- Reachability
.bitmapwriter. - delta
- Git delta encoding (used by
OFS_DELTA/REF_DELTApacked objects). - ewah
- EWAH bitmap compression — the encoding git’s reachability
.bitmapuses.
Structs§
- Pack
- A packfile loaded into memory, addressable by object offset.
- Pack
Index - A parsed v2 pack index (
*.idx): the id→offset map for aPack. - Pack
Output - The result of
PackWriter::finish: the two files and their shared name. - Pack
Verification - The outcome of
verify_pack. - Pack
Writer - Accumulates objects and emits a packfile plus its index.
Functions§
- explode_
pack - Sequentially decodes every object in a raw packfile, resolving all deltas, and returns the objects with their ids.
- explode_
pack_ prefix - Like
explode_pack, but also returns the number of bytes the packfile occupied (its header, entries, and trailing checksum) — so a caller holding several packfiles concatenated back to back (as apackfile-urisfetch yields: the inline pack followed by each downloaded pack) can decode them in sequence, advancing by the returned length. Trailing bytes beyond the checksum are left for the next call. - pack_
frame_ end - Returns the offset just past the packfile frame that begins at
offset(the start of the next entry), without resolving any delta. - verify_
pack - Verifies a packfile against its
.idx(git verify-pack).
Type Aliases§
- Exploded
Object - A fully-resolved object recovered from a packfile: its id, type, and bytes.
- External
Resolver - Resolves a
REF_DELTAbase object that is not in the current pack — i.e. a callback into the surrounding object database, returning(type, payload).