Skip to content

Add fixup/squash commit actions with instant variants - #3

Merged
sei40kr merged 4 commits into
mainfrom
claude/magit-instant-rebase-gsdhev
Jul 26, 2026
Merged

sei40kr merged 4 commits into
mainfrom
claude/magit-instant-rebase-gsdhev

Conversation

@sei40kr

@sei40kr sei40kr commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Implement fixup and squash commit operations, including instant variants that immediately fold the marker commit into its target via autosquash rebase.

Summary

This adds four new transient menu actions to the commit menu (f, F, s, S):

  • Fixup (f): Creates a fixup! marker commit for a picked target
  • Instant fixup (F): Creates the marker commit and immediately rebases it in with sequence.editor=true (magit-commit-instant-fixup)
  • Squash (s): Creates a squash! marker commit for a picked target
  • Instant squash (S): Creates the marker commit and immediately rebases it in, stopping for the editor to combine messages (magit-commit-instant-squash)

Key Changes

  • New MeldKind enum (src/app/ops/commit.rs): Abstracts over fixup vs. squash behavior with a shared as_str() method for option names
  • autosquash_marker_commit() method: Opens a picker over commits, validates that there are staged changes (or --all flag), then creates the marker commit with git commit --fixup=<rev> or --squash=<rev>
  • instant_rebase() method: For instant variants, runs the marker commit synchronously (or in background for fixup), then performs an interactive autosquash rebase with sequence.editor=true to skip editor stops. For squash, the rebase takes the foreground editor handoff to combine messages
  • Transient menu updates (src/ui/transient.rs): Added four new TransientAction variants and menu items to the COMMIT transient definition
  • Router updates (src/app/ops/mod.rs): Wired the new actions into invoke_transient()
  • Test coverage (tests/git_integration.rs): Added instant_fixup_folds_staged_changes_into_target() integration test verifying the full command sequence
  • Visibility change (src/app/workers.rs): Made push_process_entry() public for the instant rebase flow to log the marker commit

Implementation Details

The instant variants never stop for an editor:

  • Instant fixup: Both commit and rebase run in the background via run_git_seq_bg()
  • Instant squash: Commit runs synchronously here (to catch errors early), then the rebase takes the foreground editor handoff via EditorRequest with GIT_SEQUENCE_EDITOR=true

Root commits are handled by detecting whether the target has a parent; if not, rebase uses --root as the onto point.

https://claude.ai/code/session_012Cx7mBkk3WHNtg124U85qV

claude added 4 commits July 26, 2026 08:19
The commit menu gains f/s (create a fixup!/squash! commit for a picked
target) and F/S, the equivalents of magit-commit-instant-fixup/-squash:
after creating the marker commit, an autosquash rebase immediately folds
it into its target. The rebase todo is accepted as generated via
sequence.editor=true; instant fixup runs fully in the background, while
instant squash takes the foreground editor handoff since git opens
$EDITOR to combine the two messages. Targets without a parent rebase
with --root, and a dirty worktree is carried across via --autostash.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Cx7mBkk3WHNtg124U85qV
A stringly-typed kind parameter allowed nonsense values and the helpers
were named after only one of the two variants. The marker flavor is now a
two-variant Marker enum, and the helpers are named for what they do:
marker_commit creates the fixup!/squash! commit, instant_rebase folds it
into its target.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Cx7mBkk3WHNtg124U85qV
Marker named the enum after the commit it creates, but what the two
variants actually distinguish is the flavor of autosquash rebase the
marker commit asks for. Rename to AutosquashKind and spell out in
autosquash_marker_commit which marker the helper creates.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Cx7mBkk3WHNtg124U85qV
Fixup and squash are not kinds of autosquash — autosquash is the
mechanism that processes both markers in one rebase. What the two
variants are is the meld todo actions (git's own todo help: "meld into
previous commit"), the vocabulary rebase.rs already uses for
TodoAction::Fixup/Squash.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Cx7mBkk3WHNtg124U85qV
@sei40kr
sei40kr merged commit 01a4e25 into main Jul 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants