Skip to content

Support interactive rebase from root commit via r i - #6

Open
sei40kr wants to merge 1 commit into
mainfrom
claude/interactive-rebase-range-issue-i9gth6
Open

Support interactive rebase from root commit via r i#6
sei40kr wants to merge 1 commit into
mainfrom
claude/interactive-rebase-range-issue-i9gth6

Conversation

@sei40kr

@sei40kr sei40kr commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

Extends the interactive rebase command (r i) to support rebasing from the root commit (a parentless commit) by passing --root to git instead of a base revision. This aligns with Magit's behavior where r i rebases the chosen commit itself along with everything above it.

Changes

  • src/app/ops/rebase.rs:

    • Changed picker prompt from "Interactive rebase onto" to "Rebase from" to clarify semantics
    • Detect when the selected commit has no parent and pass --root to git instead of {rev}^
    • Handle --root specially in open_todo_editor: use HEAD as the range instead of {base}..HEAD
    • Update pane titles to distinguish "from the root" vs "onto {base}"
    • Update operation descriptions in the rebase confirmation flow
  • src/ui/pane.rs:

    • Clarified RebaseTodoState::base documentation to note that it can be the literal string --root
  • tests/git_integration.rs:

    • Added prepared_todo_rebases_the_whole_history_via_root() test that verifies:
      • Interactive rebase with --root spans the entire history
      • Fixup commits can be melded into the root commit itself
      • The rebase completes successfully

Implementation Details

The key insight is that when rebasing a parentless commit, git requires --root instead of a base revision. The implementation detects this by attempting to resolve {rev}^ and falling back to --root if it doesn't exist. This allows the todo list to include all commits from the root, enabling autosquash to meld fixup commits into the root commit itself.

https://claude.ai/code/session_015ZhEru79eHQaxhwGqGS2Nf

Magit's 'r i' rebases the commit at point *and* everything above it: it
hands git the commit's parent (or --root for a parentless commit). rugit
passed the picked rev straight through as the base, so the rev-list range
base..HEAD excluded the very commit the user pointed at — off by one
against Magit.

Resolve the picked rev to rev^ in the picker continuation, falling back
to --root when it has no parent, and teach the todo editor the --root
case (whole-history span, flag passed through at confirm). The onto-
upstream/elsewhere interactive variants keep their exclusive semantics,
which match Magit.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015ZhEru79eHQaxhwGqGS2Nf
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