pub struct Commit {
pub id: CommitId,
pub parents: SmallVec<[CommitId; 2]>,
pub root: Root,
pub seq: u64,
pub message: Option<String>,
pub ops: Vec<Op>,
}Expand description
One immutable point in a branch’s history.
A commit owns a whole root, but roots are structurally shared, so the marginal cost of a commit is the path it rewrote, not the database.
Fields§
§id: CommitIdContent address: blake3(parent ids ‖ message ‖ canonical-encoded ops).
parents: SmallVec<[CommitId; 2]>Zero parents for the genesis commit, one normally, two for a merge.
root: RootThe state of the database after this commit.
seq: u64Monotonic along the first-parent chain; the genesis commit is 0.
message: Option<String>Optional human-readable message. Part of the content address, so the same change under a different message is a different commit.
ops: Vec<Op>This commit’s change set, sorted by key.
Implementations§
Source§impl Commit
impl Commit
Sourcepub fn compute_id(
parents: &[CommitId],
message: Option<&str>,
ops: &[Op],
) -> CommitId
pub fn compute_id( parents: &[CommitId], message: Option<&str>, ops: &[Op], ) -> CommitId
Compute the content address of a commit from its parents, message and change set.
DESIGN §4.1 defines the id as blake3(parent ids ‖ message ‖ canonical-encoded ops). seq and wall-clock time take no part, so the
same change with the same message applied to the same parents is the
same commit everywhere.
The message is encoded as an optional length-prefixed string, so a commit with no message, one with an empty message and one with a real message are three different commits.
Sourcepub fn first_parent(&self) -> Option<CommitId>
pub fn first_parent(&self) -> Option<CommitId>
The first parent, i.e. the previous commit on this branch.