Add single-commit rebase actions and subset rebase support - #7
Merged
Conversation
Bring the rebase transient up to parity with magit-rebase:
- p: rebase onto the push-remote branch
- s: rebase a subset (--onto, picking the new base and the first
commit to move)
- f: autosquash fixup!/squash! commits onto the merge base with the
upstream, accepting the todo as generated
- m/w/k: modify, reword, or remove a single commit — the prepared-plan
machinery generates the todo with just that commit's action changed
and hands it to git via GIT_SEQUENCE_EDITOR/sequence.editor, so
reword works in one step (Magit's instant reword) and edit/drop run
headlessly in the background
The menu is regrouped like Magit's ("Rebase onto" / "Rebase"), and the
todo-editor title now names the --onto target for subset rebases.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QvRnSchVxkwG6csZ6oLrkp
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QvRnSchVxkwG6csZ6oLrkp
Both the --autosquash switch and the `f` action in the rebase transient spelled out "Autosquash fixup and squash commits", which is far longer than every neighbouring entry and made the menu column ragged. "Autosquash" already names the operation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implement Magit-style single-commit rebase operations and subset rebasing, expanding the rebase menu with six new actions that operate on individual commits or commit ranges without opening the interactive editor.
Summary
This change adds support for five new rebase operations that mirror Magit's rebase menu:
p): rebase the current branch onto its configured push-remotes): interactively select a base and starting commit, then rebase just that span with--ontof): automatically foldfixup!/squash!commits into their targetsm): pick a commit and stop the rebase there for amendingw): pick a commit and open$EDITORonly for its messagek): pick a commit and drop it via a prepared rebase planThe key insight is that single-commit actions (modify/reword/remove) reuse the interactive rebase machinery without opening the editor pane: a plan is generated with the chosen commit's action pre-set and handed directly to git via
GIT_SEQUENCE_EDITOR=cp.Key Changes
src/app/ops/rebase.rs:RebaseOntoPushRemotehandler that rebases onto{remote}/{branch}RebaseSubsethandler with two-picker flow (base, then starting commit)RebaseAutosquashhandler that applies--autosquashto a generated planlist_plan_entries()to generate the pick-everything plan for a rangepick_instant_todo()to open a picker for single-commit actionsinstant_todo_rebase()to prepare and execute a rebase with a pre-set action on one commit:editanddrop: runs in background withsequence.editor=cpinstalling the planreword: opens$EDITORfor the message via foreground handoffopen_todo_editor()to use the extractedlist_plan_entries()and handle--ontoin the pane titlesrc/ui/transient.rs:TransientActionvariantssrc/app/ops/mod.rs:rebase_action()dispatch to handle all new action variantssrc/app/ops/remote.rs:push_remote()public (was private) so rebase can access ittests/git_integration.rs:three_commit_repo()helper for rebase testssingle_action_plan()helper to generate prepared plansprepared_drop_plan_removes_a_commit_headlessly(): verifies drop works without editorprepared_edit_plan_stops_at_the_commit_for_amending(): verifies edit stops cleanlyprepared_reword_plan_rewords_a_commit_in_one_step(): verifies reword opens only message editorsubset_rebase_moves_only_the_chosen_span(): verifies--ontomoves only the spanImplementation Details
.git/rugit-rebase-todoand useGIT_SEQUENCE_EDITOR=cpto install it, avoiding any interactive editor for edit/drop$EDITORopens for the message and the rebase finishes automatically--ontoto move only the selected span; the base is the parent of the starting commit (inclusive)https://claude.ai/code/session_01QvRnSchVxkwG6csZ6oLrkp