Skip to main content

Commit

Struct Commit 

Source
pub struct Commit;
Expand description

Commit operations — create and amend commits.

Uses the git CLI.

Implementations§

Source§

impl Commit

Source

pub fn create(repo: &Repository, message: &str) -> Result<()>

Create a new commit with the given message.

Only staged changes are committed. Equivalent to git commit -m <message>.

Source

pub fn amend(repo: &Repository, message: &str) -> Result<()>

Amend the most recent commit, replacing its message and incorporating any currently staged changes.

Equivalent to git commit --amend -m <message>.

Source

pub fn augment(repo: &Repository, target: &str, message: &str) -> Result<()>

MG.42-E1: record a squash! marker for target carrying the user’s own note — magit’s A augment.

--squash with -m is additive, not conflicting: git writes squash! <subject> as the first line and appends the message below it. That is precisely augment’s semantics — a squash the author annotated — so no second commit step is needed.

Source

pub fn merge_with_message( repo: &Repository, branch: &str, message: &str, ) -> Result<()>

MG.42-E1: merge branch with a message the user wrote — magit’s merge e edit.

Genuinely different from the n don’t-commit row: this completes the merge in one step with an authored message, rather than leaving a staged merge for a separate commit.

Source

pub fn reword(repo: &Repository, message: &str) -> Result<()>

MG.42-E1: replace the last commit’s MESSAGE ONLY, leaving the index alone — magit’s w reword.

--only is the whole difference from Self::amend. Without it, anything currently staged is swept into the commit being reworded, which is a content change the user did not ask for and would not see coming from a row labelled “reword”.

Auto Trait Implementations§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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.