Skip to main content

Module magit_global_mode

Module magit_global_mode 

Source
Expand description

MG.1: magit-global universal minor mode — entry-point chords.

Activates on every buffer (Universal policy) so C-x g, C-c g, and C-c f work from any buffer kind — document, help, file tree, oil, terminal, etc.

Fold audit fix (MG.8): also contributes the action:magit-global-* handlers the root dispatch transient’s items fire. These exist precisely because TransientItemKind::Action dispatch resolves through ActionHandlerRegistry::lookup only — never through the ex-command path — so an item that should “open the log buffer from wherever the user happens to be” can’t just target the magit-log ex-command’s CommandId; nothing in ActionHandlerRegistry answers for it. Every OTHER action:magit-* handler in this crate is registered per-buffer from on_activate (only live while its owning magit buffer is the one that activated it) — these are global instead, via [Mode::action_handlers], because this mode’s ActivationPolicy::Universal means they’re needed everywhen, matching what a global dispatch menu needs.

Bug fix history: an earlier version registered these from on_activate itself, gated by a OnceLock so the process-lifetime handlers were only installed once despite Universal re-running on_activate on every buffer. That was fundamentally racy: Mode::on_activate’s returned future runs through a “try-sync-then-spawn” cascade (lattice_mode::registry::ModeRegistry::spawn_cascade) shared with every OTHER mode admitted by the same activation batch — if any mode ordered earlier in that batch has real async work, the WHOLE batch (including this mode’s own, otherwise-synchronous, step) defers to a background task with no guarantee it completes before the user’s next keystroke. Symptom: C-c g/C-c f opened the transient fine (its CommandIds resolve independently, from CommandRegistry at install() time), but every item’s key just dismissed the menu and did nothing — ActionHandlerRegistry::lookup returned None because the handler registration hadn’t run yet, or (with a separate now-fixed bug where the guard latched on the FIRST ATTEMPT regardless of success) had permanently failed to run at all. [Mode::action_handlers] sidesteps the whole hazard: the host’s register_mode_action_handlers walks every mode’s contributed list in a plain synchronous for loop at boot, strictly after the command registry is frozen — no cascade, no Universal-activation timing dependency, no per-buffer state needed (these handlers close over nothing but read ActionContext at call time), so no on-activate registration is needed at all.

Structs§

CommitOp
MG.20: an operation that acts on ONE commit.
GitStep
MG.42-E2: one step of a composite operation.
MagitGlobalMode
RemoteFlag
MG.17a: one argument on a RemoteOp.
RemoteOp
SubtreeOp
One git subtree operation.

Enums§

RemoteArgKind
MG.17b: what an argument contributes to the command line.
RemoteTarget
MG.16: one detached git operation, named once.

Functions§

resolve_upstream
MG.41c: resolve @{upstream} into the remote branch pair a push destination needs.
spawn_clone
Clone url into dest, off the actor thread.
spawn_commit_op
Run a CommitOp against commit, off the actor thread.
spawn_computed
MG.43d: run a multi-step operation whose LATER steps depend on state only discoverable part-way through.
spawn_git
spawn_git_sequence
MG.42-E2: run several git invocations in order as ONE operation.
spawn_gitignore
MG.23c1: append pattern to the repository’s .gitignore.
spawn_rebase_verb
MG.43c: run a one-commit interactive rebase off the actor thread.
spawn_rebase_verb_with
spawn_remote_op
spawn_remote_op_to
Run op off the actor thread and return the optimistic echo.
spawn_subtree_op
Run a subtree operation off the actor thread, reporting completion.