pub struct Commit<'repo> {
pub id: ObjectId,
pub data: Vec<u8>,
pub repo: &'repo Repository,
}
Expand description
A decoded commit object with access to its owning repository.
Fields§
§id: ObjectId
The id of the commit
data: Vec<u8>
The fully decoded commit data
repo: &'repo Repository
The owning repository.
Implementations§
Source§impl Commit<'_>
Remove Lifetime
impl Commit<'_>
Remove Lifetime
Sourcepub fn detached(&self) -> ObjectDetached
pub fn detached(&self) -> ObjectDetached
Create an owned instance of this object, copying our data in the process.
Sourcepub fn detach(self) -> ObjectDetached
pub fn detach(self) -> ObjectDetached
Sever the connection to the Repository
and turn this instance into a standalone object.
Source§impl<'repo> Commit<'repo>
impl<'repo> Commit<'repo>
Sourcepub fn short_id(&self) -> Result<Prefix, Error>
pub fn short_id(&self) -> Result<Prefix, Error>
Turn this objects id into a shortened id with a length in hex as configured by core.abbrev
.
Sourcepub fn message(&self) -> Result<MessageRef<'_>, Error>
pub fn message(&self) -> Result<MessageRef<'_>, Error>
Parse the commits message into a MessageRef
Sourcepub fn message_raw(&self) -> Result<&BStr, Error>
pub fn message_raw(&self) -> Result<&BStr, Error>
Decode the commit object until the message and return it.
Sourcepub fn message_raw_sloppy(&self) -> &BStr
pub fn message_raw_sloppy(&self) -> &BStr
Obtain the message by using intricate knowledge about the encoding, which is fastest and can’t fail at the expense of error handling.
Sourcepub fn time(&self) -> Result<Time, Error>
pub fn time(&self) -> Result<Time, Error>
Decode the commit and obtain the time at which the commit was created.
For the time at which it was authored, refer to .decode()?.author.time
.
Sourcepub fn decode(&self) -> Result<CommitRef<'_>, Error>
pub fn decode(&self) -> Result<CommitRef<'_>, Error>
Decode the entire commit object and return it for accessing all commit information.
It will allocate only if there are more than 2 parents.
Note that the returned commit object does make lookup easy and should be used for successive calls to string-ish information to avoid decoding the object more than once.
Sourcepub fn iter(&self) -> CommitRefIter<'_> ⓘ
pub fn iter(&self) -> CommitRefIter<'_> ⓘ
Return an iterator over tokens, representing this commit piece by piece.
Return the commits author, with surrounding whitespace trimmed.
Sourcepub fn committer(&self) -> Result<SignatureRef<'_>, Error>
pub fn committer(&self) -> Result<SignatureRef<'_>, Error>
Return the commits committer. with surrounding whitespace trimmed.
Sourcepub fn parent_ids(&self) -> impl Iterator<Item = Id<'repo>> + '_
pub fn parent_ids(&self) -> impl Iterator<Item = Id<'repo>> + '_
Decode this commits parent ids on the fly without allocating.
Sourcepub fn tree(&self) -> Result<Tree<'repo>, Error>
pub fn tree(&self) -> Result<Tree<'repo>, Error>
Parse the commit and return the tree object it points to.
Sourcepub fn tree_id(&self) -> Result<Id<'repo>, Error>
pub fn tree_id(&self) -> Result<Id<'repo>, Error>
Parse the commit and return the tree id it points to.
Sourcepub fn ancestors(&self) -> Platform<'repo>
pub fn ancestors(&self) -> Platform<'repo>
Obtain a platform for traversing ancestors of this commit.