Pure encoder and strict positional parser for Gitility bundle format v1.
Opening verifies the header, EOF trailer, TOC identity, bounds, section
tiling, pack/index pairing, and the complete metadata/ref grammar. Unknown
metadata keys and FILE kinds remain minor-additive space, except for the
reserved shallow_roots feature gate, which v1 readers refuse rather than
silently misreading shallow history. Section payload hashes are
intentionally deferred to Gitility.Bundle.verify/1.
Summary
Functions
Encodes the fixed bundle v1 header.
Encodes a deterministically ordered bundle v1 table of contents.
Encodes the fixed bundle v1 trailer.
The format's TOC size ceiling; readers reject and writers refuse beyond it.
Parses and structurally validates one bundle without hashing section payloads.
Types
@type file_entry() :: %{ kind: file_kind(), name: binary(), offset: non_neg_integer(), length: pos_integer(), sha256: <<_::256>> }
@type file_kind() :: :pack | :idx | {:unknown, 0..255}
@type ref_entry() :: %{ name: binary(), target: binary(), kind: Gitility.Object.object_type(), peeled: binary() | nil }
@type toc() :: %{ format_major: pos_integer(), format_minor: non_neg_integer(), hash_algorithm: Gitility.OID.algorithm(), generation: pos_integer(), metadata: %{required(binary()) => binary()}, files: [file_entry()], sections: [file_entry()], refs: [ref_entry()], toc_offset: non_neg_integer(), toc_len: non_neg_integer(), toc_sha256: <<_::256>>, file_size: non_neg_integer() }
Functions
@spec encode_header() :: binary()
Encodes the fixed bundle v1 header.
Encodes a deterministically ordered bundle v1 table of contents.
@spec encode_trailer(non_neg_integer(), non_neg_integer(), <<_::256>>) :: binary()
Encodes the fixed bundle v1 trailer.
@spec max_toc_len() :: pos_integer()
The format's TOC size ceiling; readers reject and writers refuse beyond it.
@spec parse(Path.t()) :: {:ok, toc()} | {:error, Gitility.Error.t()}
Parses and structurally validates one bundle without hashing section payloads.