Struct git2::Commit

source ·
pub struct Commit<'repo> { /* private fields */ }
Expand description

A structure to represent a git commit

Implementations§

source§

impl<'repo> Commit<'repo>

source

pub fn id(&self) -> Oid

Get the id (SHA1) of a repository commit

source

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.

source

pub fn tree(&self) -> Result<Tree<'repo>, Error>

Get the tree pointed to by a commit.

source

pub fn raw(&self) -> *mut git_commit

Get access to the underlying raw pointer.

source

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

source

pub 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.

source

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

source

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

source

pub fn message_raw_bytes(&self) -> &[u8]

Get the full raw message of a commit.

source

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

source

pub fn header_field_bytes<T: IntoCString>(&self, field: T) -> Result<Buf, Error>

Get an arbitrary header field.

source

pub fn raw_header_bytes(&self) -> &[u8]

Get the full raw text of the commit header.

source

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.

source

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

source

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.

source

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.

source

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.

source

pub fn parents<'a>(&'a self) -> Parents<'a, 'repo>

Creates a new iterator over the parents of this commit.

source

pub fn parent_ids(&self) -> ParentIds<'_>

Creates a new iterator over the parents of this commit.

source

pub fn author(&self) -> Signature<'_>

Get the author of this commit.

source

pub fn author_with_mailmap( &self, mailmap: &Mailmap, ) -> Result<Signature<'static>, Error>

Get the author of this commit, using the mailmap to map names and email addresses to canonical real names and email addresses.

source

pub fn committer(&self) -> Signature<'_>

Get the committer of this commit.

source

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.

source

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.

source

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.

source

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.

source

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.

source

pub fn as_object(&self) -> &Object<'repo>

Casts this Commit to be usable as an Object

source

pub fn into_object(self) -> Object<'repo>

Consumes Commit to be returned as an Object

Trait Implementations§

source§

impl<'repo> Clone for Commit<'repo>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'repo> Debug for Commit<'repo>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'repo> Drop for Commit<'repo>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'repo> Freeze for Commit<'repo>

§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T