pub struct Commit<'repo> { /* private fields */ }
Expand description
A structure to represent a git commit
Implementations
sourceimpl<'repo> Commit<'repo>
impl<'repo> Commit<'repo>
sourcepub fn tree_id(&self) -> Oid
pub fn tree_id(&self) -> Oid
Get the id of the tree pointed to by this commit.
No attempts are made to fetch an object from the ODB.
sourcepub fn raw(&self) -> *mut git_commit
pub fn raw(&self) -> *mut git_commit
Get access to the underlying raw pointer.
sourcepub fn message(&self) -> Option<&str>
pub fn message(&self) -> Option<&str>
Get the full message of a commit.
The returned message will be slightly prettified by removing any potential leading newlines.
None
will be returned if the message is not valid utf-8
sourcepub fn message_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn message_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Get the full message of a commit as a byte slice.
The returned message will be slightly prettified by removing any potential leading newlines.
sourcepub fn message_encoding(&self) -> Option<&str>
pub fn message_encoding(&self) -> Option<&str>
Get the encoding for the message of a commit, as a string representing a standard encoding name.
None
will be returned if the encoding is not known
sourcepub fn message_raw(&self) -> Option<&str>
pub fn message_raw(&self) -> Option<&str>
Get the full raw message of a commit.
None
will be returned if the message is not valid utf-8
sourcepub fn message_raw_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn message_raw_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Get the full raw message of a commit.
sourcepub fn raw_header(&self) -> Option<&str>
pub fn raw_header(&self) -> Option<&str>
Get the full raw text of the commit header.
None
will be returned if the message is not valid utf-8
sourcepub fn header_field_bytes<T: IntoCString>(&self, field: T) -> Result<Buf, Error>
pub fn header_field_bytes<T: IntoCString>(&self, field: T) -> Result<Buf, Error>
Get an arbitrary header field.
sourcepub fn raw_header_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
pub fn raw_header_bytes(&self) -> &[u8]ⓘNotable traits for &'_ [u8]impl<'_> Read for &'_ [u8]impl<'_> Write for &'_ mut [u8]
Get the full raw text of the commit header.
sourcepub fn summary(&self) -> Option<&str>
pub fn summary(&self) -> Option<&str>
Get the short “summary” of the git commit message.
The returned message is the summary of the commit, comprising the first paragraph of the message with whitespace trimmed and squashed.
None
may be returned if an error occurs or if the summary is not valid
utf-8.
sourcepub fn summary_bytes(&self) -> Option<&[u8]>
pub fn summary_bytes(&self) -> Option<&[u8]>
Get the short “summary” of the git commit message.
The returned message is the summary of the commit, comprising the first paragraph of the message with whitespace trimmed and squashed.
None
may be returned if an error occurs
sourcepub fn body(&self) -> Option<&str>
pub fn body(&self) -> Option<&str>
Get the long “body” of the git commit message.
The returned message is the body of the commit, comprising everything but the first paragraph of the message. Leading and trailing whitespaces are trimmed.
None
may be returned if an error occurs or if the summary is not valid
utf-8.
sourcepub fn body_bytes(&self) -> Option<&[u8]>
pub fn body_bytes(&self) -> Option<&[u8]>
Get the long “body” of the git commit message.
The returned message is the body of the commit, comprising everything but the first paragraph of the message. Leading and trailing whitespaces are trimmed.
None
may be returned if an error occurs.
sourcepub fn time(&self) -> Time
pub fn time(&self) -> Time
Get the commit time (i.e. committer time) of a commit.
The first element of the tuple is the time, in seconds, since the epoch. The second element is the offset, in minutes, of the time zone of the committer’s preferred time zone.
sourcepub fn parents<'a>(&'a self) -> Parents<'a, 'repo>ⓘNotable traits for Parents<'commit, 'repo>impl<'repo, 'commit> Iterator for Parents<'commit, 'repo> type Item = Commit<'repo>;
pub fn parents<'a>(&'a self) -> Parents<'a, 'repo>ⓘNotable traits for Parents<'commit, 'repo>impl<'repo, 'commit> Iterator for Parents<'commit, 'repo> type Item = Commit<'repo>;
Creates a new iterator over the parents of this commit.
sourcepub fn parent_ids(&self) -> ParentIds<'_>
pub fn parent_ids(&self) -> ParentIds<'_>
Creates a new iterator over the parents of this commit.
Get the author of this commit.
Get the author of this commit, using the mailmap to map names and email addresses to canonical real names and email addresses.
sourcepub fn committer_with_mailmap(
&self,
mailmap: &Mailmap
) -> Result<Signature<'static>, Error>
pub fn committer_with_mailmap(
&self,
mailmap: &Mailmap
) -> Result<Signature<'static>, Error>
Get the committer of this commit, using the mailmap to map names and email addresses to canonical real names and email addresses.
sourcepub fn amend(
&self,
update_ref: Option<&str>,
author: Option<&Signature<'_>>,
committer: Option<&Signature<'_>>,
message_encoding: Option<&str>,
message: Option<&str>,
tree: Option<&Tree<'repo>>
) -> Result<Oid, Error>
pub fn amend(
&self,
update_ref: Option<&str>,
author: Option<&Signature<'_>>,
committer: Option<&Signature<'_>>,
message_encoding: Option<&str>,
message: Option<&str>,
tree: Option<&Tree<'repo>>
) -> Result<Oid, Error>
Amend this existing commit with all non-None
values
This creates a new commit that is exactly the same as the old commit,
except that any non-None
values will be updated. The new commit has
the same parents as the old commit.
For information about update_ref
, see Repository::commit
.
sourcepub fn parent_count(&self) -> usize
pub fn parent_count(&self) -> usize
Get the number of parents of this commit.
Use the parents
iterator to return an iterator over all parents.
sourcepub fn parent(&self, i: usize) -> Result<Commit<'repo>, Error>
pub fn parent(&self, i: usize) -> Result<Commit<'repo>, Error>
Get the specified parent of the commit.
Use the parents
iterator to return an iterator over all parents.
sourcepub fn parent_id(&self, i: usize) -> Result<Oid, Error>
pub fn parent_id(&self, i: usize) -> Result<Oid, Error>
Get the specified parent id of the commit.
This is different from parent
, which will attempt to load the
parent commit from the ODB.
Use the parent_ids
iterator to return an iterator over all parents.
sourcepub fn into_object(self) -> Object<'repo>
pub fn into_object(self) -> Object<'repo>
Consumes Commit to be returned as an Object
Trait Implementations
Auto Trait Implementations
impl<'repo> RefUnwindSafe for Commit<'repo>
impl<'repo> !Send for Commit<'repo>
impl<'repo> !Sync for Commit<'repo>
impl<'repo> Unpin for Commit<'repo>
impl<'repo> UnwindSafe for Commit<'repo>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more