Documentation
¶
Overview ¶
Package commit defines the Commit object (CAS type 5): the analogue of a git commit — a directory root, ordered parent commits, author, committer and message, with an optional opaque signature. Encoding is RFC 8949 §4.2 core-deterministic CBOR (canonical map, integer keys), the fstree and reference convention. See architecture/commits.md.
Index ¶
Constants ¶
const ( // MaxParents is the maximum number of parent commits. MaxParents = 256 // MaxIdentityLen is the maximum byte length of an identity's name or email. MaxIdentityLen = 1024 // MaxMessageLen is the maximum message length in bytes (1 MiB). MaxMessageLen = 1 << 20 // MaxSignatureLen is the maximum Signature length in bytes (64 KiB). MaxSignatureLen = 64 << 10 // MaxPublicKeyLen is the maximum PublicKey length in bytes (16 KiB). MaxPublicKeyLen = 16 << 10 // MaxTZOffset bounds Identity.TZOffset to under a day either side of UTC. MaxTZOffset = 1439 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
Tree key.Key // DirLeaf or DirNode
Parents []key.Key // Commit keys, no duplicates
Author Identity
Committer Identity
Message string // UTF-8, may be empty
Signature []byte // raw SSHSIG blob, nil when unsigned
PublicKey []byte // signer's key, SSH wire format, nil when absent
}
Commit is a snapshot record. Parents are ordered — the first is the mainline — and empty for a root commit. Signature and PublicKey are carried opaquely; the core neither creates nor verifies signatures.
func Decode ¶
Decode parses and validates a commit. It rejects non-canonical encodings: the input must be byte-for-byte what Encode produces for the same record (extra or missing map keys, reordered keys, indefinite-length items, non-minimal integers and trailing bytes are all rejected).
func (Commit) Object ¶
Object encodes c and derives its key: type Commit, length field = the encoding's own byte length.
func (Commit) SignaturePayload ¶
SignaturePayload returns the bytes a signature runs over: the deterministic encoding without the Signature field. PublicKey stays in, so the payload binds the signer's key; set it before computing the payload.
type Identity ¶
type Identity struct {
Name string // 1..MaxIdentityLen bytes, no control characters
Email string // 0..MaxIdentityLen bytes, no control characters
When int64 // ns since the Unix epoch
TZOffset int // minutes east of UTC, -MaxTZOffset..MaxTZOffset
}
Identity is who acted and when: git's "Name <email> time tz".