Support interactive rebase from root commit via r i - #6
Open
sei40kr wants to merge 1 commit into
Open
Conversation
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
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.
Summary
Extends the interactive rebase command (
r i) to support rebasing from the root commit (a parentless commit) by passing--rootto git instead of a base revision. This aligns with Magit's behavior wherer irebases the chosen commit itself along with everything above it.Changes
src/app/ops/rebase.rs:--rootto git instead of{rev}^--rootspecially inopen_todo_editor: useHEADas the range instead of{base}..HEADsrc/ui/pane.rs:RebaseTodoState::basedocumentation to note that it can be the literal string--roottests/git_integration.rs:prepared_todo_rebases_the_whole_history_via_root()test that verifies:--rootspans the entire historyImplementation Details
The key insight is that when rebasing a parentless commit, git requires
--rootinstead of a base revision. The implementation detects this by attempting to resolve{rev}^and falling back to--rootif 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