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:u32Structs§
- Pack
Index Entry - 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_dirinto 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