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 strThe git spelling, for the echo, the confirm prompt and the ex-command’s doc line — places that show the command.
label: &'static strNC.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 strMG.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
impl CommitOp
pub const REVERT: Self
pub const CHERRY_PICK: Self
Sourcepub const RESET_WORKTREE: Self
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.
Sourcepub const REVERT_CHANGES: Self
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.
Sourcepub const CHERRY_PICK_APPLY: Self
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.
pub const RESET_SOFT: Self
pub const RESET_MIXED: Self
pub const RESET_HARD: Self
Sourcepub const RESET_KEEP: Self
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.
Sourcepub const RESET_INDEX: Self
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.
Sourcepub const COMMIT_FIXUP: Self
pub const COMMIT_FIXUP: Self
MG.41d: magit’s f fixup — record a fixup! commit that a
later rebase --autosquash folds into commit.
Sourcepub const COMMIT_SQUASH: Self
pub const COMMIT_SQUASH: Self
MG.41d: magit’s s squash — like fixup, but the message is
kept for editing when the autosquash runs.
Trait Implementations§
impl Copy for CommitOp
impl Eq for CommitOp
impl StructuralPartialEq for CommitOp
Auto Trait Implementations§
impl Freeze for CommitOp
impl RefUnwindSafe for CommitOp
impl Send for CommitOp
impl Sync for CommitOp
impl Unpin for CommitOp
impl UnsafeUnpin for CommitOp
impl UnwindSafe for CommitOp
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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