Skip to main content

Module pack

Module pack 

Source
Expand description

Git object and pack-file construction.

The LLM describes a repository as ordinary structured data - a branch name, a commit message and a list of {path, content} files - and this module turns that into real Git objects: blobs, trees, a commit, and a version-2 pack file. Object IDs are computed here, never supplied by the model, which is what makes git clone able to succeed: the SHA advertised by GET /info/refs and the SHA of the commit inside the pack returned by POST /git-upload-pack are derived from the same bytes by the same code.

Nothing is written to disk and no repository state is kept between requests. Each request rebuilds the objects from the snapshot the model (or a static/script handler) provided for that request; see CLAUDE.md for what that implies about determinism.

Deliberately not implemented: deltas (every object is stored whole), ofs-delta/ref-delta parsing, thin packs, shallow clones, annotated tag objects, submodules and symlinks.

Structs§

BuiltRepo
A repository snapshot compiled into Git objects.
CommitMeta
Author/committer identity and commit timestamp.
GitObject
A loose Git object: its type and its uncompressed body.
RepoFile
One file in the repository snapshot.

Enums§

ObjectKind
Object types that appear in a pack, with their pack type IDs.

Functions§

build_repo
Build the objects for a single-commit repository containing files.
hex_id
Render a 20-byte object ID as lowercase hex.
sha1
Convenience: SHA-1 of a single buffer.
write_pack
Serialise objects into a version-2 pack file.