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 — extended with what a jj commit carries besides: a change id, and the further terms and the labels of a conflicted tree. Encoding is RFC 8949 §4.2 core-deterministic CBOR (canonical map, integer keys), the fstree and reference convention. The key's length field is a footprint, like a directory's: the commit's own bytes plus its trees. 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 // MaxChangeIDLen is the maximum ChangeID length in bytes. MaxChangeIDLen = 64 // MaxConflictTerms is the maximum number of conflict terms after the // tree. The number is always even: a remove for every further add. MaxConflictTerms = 254 // MaxLabelLen is the maximum byte length of one conflict label. jj makes // a label from a commit's short ids and the whole first line of its // description, which nothing bounds; its adapter truncates beyond this. MaxLabelLen = 64 << 10 )
Variables ¶
This section is empty.
Functions ¶
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
ChangeID []byte // opaque, 1..MaxChangeIDLen bytes: follows the change through rewrites; nil when absent
ConflictTerms []key.Key // DirLeaf or DirNode keys, an even number; nil when the tree is resolved
ConflictLabels []string // one per term counting Tree, at least one non-empty; nil when no term is labelled
}
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.
A conflicted commit records the tree A0 − R0 + A1 − R1 + …: Tree holds A0 and ConflictTerms holds R0, A1, R1, A2, … (jj's order), so their number is even. Wherever a commit stands for a directory it stands for Tree.
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) Conflicted ¶ added in v0.0.10
Conflicted reports whether the commit records a conflicted tree.
func (Commit) Object ¶
Object encodes c and derives its key: type Commit, the length field a footprint as a directory's is — the encoding's own byte length plus the length of every tree (Trees). Parents are not counted: a parent's length would hold its own parents', so every merge would count the history its parents share twice, roughly doubling the value until it no longer fit; and a directory that holds a commit reports, through this length, the size of what is beneath it, not of its history.
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 // 0..MaxIdentityLen bytes, no control characters; empty when the user configured none
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".