Skip to main content

CommitOp

Struct CommitOp 

Source
pub struct CommitOp {
    pub what: &'static str,
    pub label: &'static str,
    pub trailing: &'static [&'static str],
    pub ex_command: &'static str,
    pub args: &'static [&'static str],
    pub confirm_action: Option<&'static str>,
}
Expand description

MG.20: an operation that acts on ONE commit.

Reset, revert and cherry-pick share a shape the RemoteOps above do not: they need a target — the commit under the cursor — so they cannot be fired from a context-free global handler. The target is resolved through crate::buffer_state::MagitView::commit_at_cursor, which every view answers for its own row format.

Fields§

§what: &'static str

The git spelling, for the echo, the confirm prompt and the ex-command’s doc line — places that show the command.

§label: &'static str

NC.4: what it does, for the notification, completed by the commit it acted on (“hard-reset to 3f2a1c0”). The argv it used to show there named a full sha and several flags, and read the same for every op in a burst.

§trailing: &'static [&'static str]

MG.41d: tokens appended AFTER the commit (see Self::argv). Empty for every op that takes none.

§ex_command: &'static str

MG.23j: this op’s ex-command name, without the :.

Load-bearing in two places beyond documentation. It is the scriptable surface (:magit-cherry-pick <sha>), and it is what the commit picker fires: a picked candidate resolves to the ex line "<ex_command> <sha>".

That shape was once the ONLY route — the host’s InvokeCommand arm destructured args away, so a value not baked into the line was lost. Fixed 2026-08-03: the arm now renders args onto the line, and both forms work. This one is kept because it is also the exact text a user would type, which keeps the picker a front-end to the command rather than a second way in.

§args: &'static [&'static str]

argv template; the resolved commit is appended.

§confirm_action: Option<&'static str>

When set, the operation asks before running and this is the -execute half it fires on “yes”. Reset –hard is the only one today: it discards working-tree changes irrecoverably, which is the same bar x / branch-delete / stash-drop are held to.

Implementations§

Source§

impl CommitOp

Source

pub const REVERT: Self

Source

pub const CHERRY_PICK: Self

Source

pub const RESET_WORKTREE: Self

MG.43f: magit’s reset w — reset the WORKING TREE to a commit, leaving HEAD and the index alone.

git restore --source <commit> --worktree is exactly this, and is why the row needs no plumbing: reset moves HEAD, and checkout <commit> -- . writes the index too. Verified against real git — a file staged before the restore is still staged after it.

The commit sits between --source and the rest, which is what trailing is for.

Source

pub const REVERT_CHANGES: Self

MG.43a: magit’s revert v — apply the inverse to the working tree and index WITHOUT committing.

--no-commit is the whole row: V records a revert commit, v leaves the reversal staged so it can be edited, split, or combined before committing. No --no-edit here because nothing is committed, so git never opens an editor to hang on.

Source

pub const CHERRY_PICK_APPLY: Self

MG.43a: magit’s cherry-pick a — apply the commit’s changes without recording a commit. Peer of Self::REVERT_CHANGES.

Source

pub const RESET_SOFT: Self

Source

pub const RESET_MIXED: Self

Source

pub const RESET_HARD: Self

Source

pub const RESET_KEEP: Self

MG.41d: magit’s k — move HEAD but refuse if that would discard uncommitted work, unlike --hard which discards it silently. No confirm precisely because git itself declines rather than destroying anything.

Source

pub const RESET_INDEX: Self

MG.41d: magit’s i — set the index to commit WITHOUT moving HEAD. The trailing -- is what makes it index-only; the same command without it moves HEAD too.

Source

pub const COMMIT_FIXUP: Self

MG.41d: magit’s f fixup — record a fixup! commit that a later rebase --autosquash folds into commit.

Source

pub const COMMIT_SQUASH: Self

MG.41d: magit’s s squash — like fixup, but the message is kept for editing when the autosquash runs.

Source

pub fn argv(&self, commit: &str) -> Vec<String>

Full argv for commit.

Trait Implementations§

Source§

impl Clone for CommitOp

Source§

fn clone(&self) -> CommitOp

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 Copy for CommitOp

Source§

impl Debug for CommitOp

Source§

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

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

impl Eq for CommitOp

Source§

impl PartialEq for CommitOp

Source§

fn eq(&self, other: &CommitOp) -> 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 CommitOp

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