Skip to main content

Module pack

Module pack 

Source
Expand description

Pack file format — many objects in one file, with a hash→offset index.

A pack is written by lit gc and read back through ObjectStore, which consults packs whenever a hash has no loose object on disk. Both sides live here so the format is defined in one place: a reader and a writer that drift apart is how packed objects become unreadable.

Layout, all integers big-endian:

pack:  "LITP" version:u32 count:u32
       then per object: type:u8 uncompressed_len:u64 compressed_len:u64 zlib-data
index: "LITI" version:u32 count:u32
       then per object, sorted by hash: hash_len:u32 hash offset:u64 crc32:u32

Structs§

PackIndexEntry
Pack index entry - maps hash to offset in pack

Constants§

INDEX_MAGIC
Index magic header
INDEX_VERSION
Index version
PACK_MAGIC
Magic header for Lit pack files
PACK_VERSION
Pack version

Functions§

load_all
Merge every pack index in packs_dir into one hash→(pack, offset) map.
load_pack_index
Load a pack index and build a hash→(pack_path, offset) map
packs_dir
The directory holding a repository’s packs.
read_pack_object
Read a single object from a pack file by offset
write_pack
Write a pack file from a set of objects.
write_pack_index
Write a pack index file