Skip to main content

CommitIntent

Enum CommitIntent 

Source
pub enum CommitIntent {
    Create,
    Amend,
    Reword,
    Augment {
        target: String,
    },
    MergeEdit {
        branch: String,
    },
    RewordCommit {
        target: String,
    },
}
Expand description

MG.42-E1: what the compose buffer is FOR.

Replaces an amend: bool that was derived by sniffing the buffer name. A bool cannot express a third intent, and the sniff coupled a buffer’s name to its behaviour — rename the buffer and the operation silently changes. The name still selects the intent, but it does so once, explicitly, at open.

Variants§

§

Create

A new commit from what is staged.

§

Amend

Replace the last commit, sweeping in anything staged.

§

Reword

Replace the last commit’s MESSAGE only, leaving the index alone. Distinct from Amend precisely because a reword that quietly absorbed staged changes would be a content change the user never asked for.

§

Augment

Record a squash! marker for target, carrying the note the user writes in the buffer. Magit’s A.

Fields

§target: String
§

MergeEdit

Complete a merge of branch with an authored message. Magit’s merge e.

Fields

§branch: String
§

RewordCommit

MG.43c: reword a commit that is NOT HEAD, via an interactive rebase. Magit’s rebase w.

Distinct from Self::Reword, which amends HEAD directly. A commit further back cannot be amended, so this replays history with that commit’s todo verb set to reword and hands git the message through GIT_EDITOR.

Fields

§target: String

Implementations§

Source§

impl CommitIntent

Source

pub fn from_buffer_name(name: &str) -> Self

Map a compose buffer’s name to its intent. Kept in ONE place so the mapping is auditable.

MR.3: read through the shared name grammar (*magit:<view>[:<repo>[:<rest>]]*) rather than by substring.

The substring form it replaces (name.contains("reword")) was fine while names held only a view word; with a repository in the name, a checkout called amend or reword would have selected the wrong operation on every commit buffer in it. Structured parsing makes that unrepresentable rather than unlikely.

A name that does not parse at all falls to Create, which is what an unrecognised compose buffer did before.

Source

pub fn augment_buffer_name(repo: &str, target: &str) -> String

The buffer name that selects this intent, for the repository labelled repo (empty outside one).

Source

pub fn merge_edit_buffer_name(repo: &str, branch: &str) -> String

Source

pub fn reword_commit_buffer_name(repo: &str, target: &str) -> String

Source

pub fn seeds_prior_message(&self) -> bool

Does the buffer open pre-filled with the previous message?

Source

pub fn seed_source(&self) -> Option<&str>

The commit whose message seeds the buffer, when it is not HEAD.

Trait Implementations§

Source§

impl Clone for CommitIntent

Source§

fn clone(&self) -> CommitIntent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for CommitIntent

Source§

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

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

impl Eq for CommitIntent

Source§

impl PartialEq for CommitIntent

Source§

fn eq(&self, other: &CommitIntent) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CommitIntent

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more