pub struct Commit {
pub tree: ObjectId,
pub parents: Vec<ObjectId>,
pub author: Vec<u8>,
pub committer: Vec<u8>,
pub encoding: Option<Vec<u8>>,
pub message: Vec<u8>,
}Expand description
A parsed, canonical representation of the commit headers this crate understands.
Commit preserves tree, parent, author, committer, encoding, and
message bytes. It intentionally does not retain unknown headers,
continuation blocks such as gpgsig, mergetags, or their original ordering.
Use EncodedObject when commit object bytes or object ids must be
preserved exactly.
Fields§
§tree: ObjectId§parents: Vec<ObjectId>§committer: Vec<u8>§encoding: Option<Vec<u8>>§message: Vec<u8>Implementations§
Source§impl Commit
impl Commit
Sourcepub fn parse(format: ObjectFormat, bytes: &[u8]) -> Result<Self>
pub fn parse(format: ObjectFormat, bytes: &[u8]) -> Result<Self>
Parse a commit into the canonical typed representation.
Unknown headers and continuation records are accepted but not retained.
Use EncodedObject for byte-exact commit preservation.
pub fn parse_ref<'a>( format: ObjectFormat, bytes: &'a [u8], ) -> Result<CommitRef<'a>>
Sourcepub fn write(&self) -> Vec<u8> ⓘ
pub fn write(&self) -> Vec<u8> ⓘ
Serialize the canonical typed commit representation.
The output contains only the fields represented by Commit; it is not
intended to reproduce raw input bytes that contained unknown headers,
signatures, or mergetags.
Parse the raw author line into a typed
Signature parse-view, or None if the stored bytes are not a
well-formed git identity.
This is a read-only lens: it does not touch the raw author bytes, which
remain the source of truth for Commit::write. The returned signature
re-serializes byte-identically to author (see
Signature::to_ident_bytes).
Sourcepub fn committer_signature(&self) -> Option<Signature>
pub fn committer_signature(&self) -> Option<Signature>
Parse the raw committer line into a typed
Signature parse-view, or None if the stored bytes are not a
well-formed git identity. Read-only over the raw bytes, exactly like
Commit::author_signature.