Skip to content

Add single-commit rebase actions and subset rebase support - #7

Merged
sei40kr merged 3 commits into
mainfrom
claude/rugit-rebase-missing-features-gz9v1z
Aug 3, 2026
Merged

Add single-commit rebase actions and subset rebase support#7
sei40kr merged 3 commits into
mainfrom
claude/rugit-rebase-missing-features-gz9v1z

Conversation

@sei40kr

@sei40kr sei40kr commented Jul 26, 2026

Copy link
Copy Markdown
Owner

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:

  • Rebase onto push-remote (p): rebase the current branch onto its configured push-remote
  • Rebase a subset (s): interactively select a base and starting commit, then rebase just that span with --onto
  • Autosquash (f): automatically fold fixup!/squash! commits into their targets
  • Modify/Edit commit (m): pick a commit and stop the rebase there for amending
  • Reword commit (w): pick a commit and open $EDITOR only for its message
  • Remove commit (k): pick a commit and drop it via a prepared rebase plan

The 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:

    • Added RebaseOntoPushRemote handler that rebases onto {remote}/{branch}
    • Added RebaseSubset handler with two-picker flow (base, then starting commit)
    • Added RebaseAutosquash handler that applies --autosquash to a generated plan
    • Extracted list_plan_entries() to generate the pick-everything plan for a range
    • Added pick_instant_todo() to open a picker for single-commit actions
    • Added instant_todo_rebase() to prepare and execute a rebase with a pre-set action on one commit:
      • For edit and drop: runs in background with sequence.editor=cp installing the plan
      • For reword: opens $EDITOR for the message via foreground handoff
    • Refactored open_todo_editor() to use the extracted list_plan_entries() and handle --onto in the pane title
  • src/ui/transient.rs:

    • Added six new TransientAction variants
    • Reorganized the rebase menu into "Rebase onto" and "Rebase" groups
    • Added menu items for all six new actions with Magit-compatible key bindings
  • src/app/ops/mod.rs:

    • Updated rebase_action() dispatch to handle all new action variants
  • src/app/ops/remote.rs:

    • Made push_remote() public (was private) so rebase can access it
  • tests/git_integration.rs:

    • Added three_commit_repo() helper for rebase tests
    • Added single_action_plan() helper to generate prepared plans
    • Added three integration tests:
      • prepared_drop_plan_removes_a_commit_headlessly(): verifies drop works without editor
      • prepared_edit_plan_stops_at_the_commit_for_amending(): verifies edit stops cleanly
      • prepared_reword_plan_rewords_a_commit_in_one_step(): verifies reword opens only message editor
      • subset_rebase_moves_only_the_chosen_span(): verifies --onto moves only the span

Implementation Details

  • Single-commit actions write a prepared todo to .git/rugit-rebase-todo and use GIT_SEQUENCE_EDITOR=cp to install it, avoiding any interactive editor for edit/drop
  • Reword uses foreground handoff so $EDITOR opens for the message and the rebase finishes automatically
  • Subset rebase uses --onto to move only the selected span; the base is the parent of the starting commit (inclusive)
  • All new actions respect `--aut

https://claude.ai/code/session_01QvRnSchVxkwG6csZ6oLrkp

claude and others added 3 commits July 26, 2026 17:27
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.
@sei40kr
sei40kr merged commit db02917 into main Aug 3, 2026
3 checks passed
@sei40kr
sei40kr deleted the claude/rugit-rebase-missing-features-gz9v1z branch August 3, 2026 18:01
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