Skip to main content

Module object

Module object 

Source
Expand description

Canonical git object bytes — the unit a git-format znippy archive stores.

An archive entry’s payload is the canonical serialization of a git object: "<type> <size>\0<content>". That is precisely the byte string a git object id is the hash of, so

  • object_type and object_size are derived from the stored bytes with no out-of-band state (P-2: the plugin writes only what it can see), and
  • a read-back is checkable by construction — re-hash the bytes and compare against the relative_path, which is the oid hex. That is an applied output, not a state round-trip (LAW 2).

Nothing here allocates per object beyond the borrow it returns, and nothing panics on malformed input (P-4).

Structs§

CommitHeader
The header fields of a commit payload that the commit graph needs.
GitObject
A parsed canonical git object: its type and the content after the NUL.
TreeEntry
One entry of a tree object.

Enums§

GitHashKind
Which hash a repository’s object ids use. gunnar defaults to sha256 (D11); sha1 stays supported.
GitObjectKind
The four git object types.
PackFileKind
The two files a packed git object store is made of.

Constants§

PACKFILE_TYPE
object_type for a pack-<id>.pack.
PACK_INDEX_TYPE
object_type for a pack-<id>.idx.

Functions§

canonical
Build canonical bytes from a type and content. Used by tests and by any writer that has the content in hand.
is_oid_path
True when path is shaped like a git oid used as a relative_path: the whole path is 40 or 64 lowercase hex characters. Deliberately strict — git writes lowercase hex everywhere, and accepting mixed case would put two spellings of one object in one archive.
pack_path_kind
True when path is pack-<oid hex>.<ext>, the name git itself gives the files in objects/pack, and the name gunnar seals them under.
parse_canonical
Parse "<type> <size>\0<content>".
parse_commit
Parse a commit payload’s header block (everything before the first blank line). Unknown headers are ignored; a malformed one is skipped (P-4).
tree_entries
Parse a tree payload: a sequence of <mode> <name>\0<raw oid>.