Struct git2::Commit
[−]
[src]
pub struct Commit<'repo> { // some fields omitted }
A structure to represent a git commit
Methods
impl<'repo> Commit<'repo>
fn id(&self) -> Oid
Get the id (SHA1) of a repository commit
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.
fn tree(&self) -> Result<Tree<'repo>, Error>
Get the tree pointed to by a commit.
fn raw(&self) -> *mut git_commit
Get access to the underlying raw pointer.
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
fn message_bytes(&self) -> &[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.
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
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
fn message_raw_bytes(&self) -> &[u8]
Get the full raw message of a commit.
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
fn raw_header_bytes(&self) -> &[u8]
Get the full raw text of the commit header.
fn summary(&mut 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.
fn summary_bytes(&mut 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
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.
fn parents<'a>(&'a self) -> Parents<'a, 'repo>
Creates a new iterator over the parents of this commit.
fn parent_ids(&self) -> ParentIds
Creates a new iterator over the parents of this commit.
fn author(&self) -> Signature
Get the author of this commit.
fn committer(&self) -> Signature
Get the committer of this commit.
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 new
.
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.
fn parent_id(&self, i: usize) -> Result<Oid, Error>
Get the specified parent id of the commit.
This is different from parent
, which will attemptstempt to load the
parent commit from the ODB.
Use the parent_ids
iterator to return an iterator over all parents.
fn as_object(&self) -> &Object<'repo>
Casts this Commit to be usable as an Object