Skip to content

Display rebase progress in status buffer - #4

Open
sei40kr wants to merge 3 commits into
mainfrom
claude/magit-rebase-progress-cpwl93
Open

Display rebase progress in status buffer#4
sei40kr wants to merge 3 commits into
mainfrom
claude/magit-rebase-progress-cpwl93

Conversation

@sei40kr

@sei40kr sei40kr commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Add a rebase-sequence section to the status buffer showing the progress of an in-progress rebase, matching Magit's display style.

Summary

This change adds comprehensive rebase progress tracking to the status buffer. When a rebase is in progress (either interactive or am-backend), a new "Rebasing X onto Y" section appears at the top, displaying:

  • Pending commits (remaining todo lines, newest first)
  • The commit where the rebase stopped (if any)
  • Already-applied commits
  • The base being rebased onto

Each row is a clickable commit section, allowing users to visit commits during a rebase.

Key changes

  • Parser additions (git/parse.rs):

    • parse_hash_subject(): Extract commit hash and subject from git log output
    • parse_mail_patch(): Parse mailbox-format patch files from am-backend rebases
    • assemble_rebase_steps(): Assemble the display rows from sequencer state (todo, stop point, applied commits, base)
  • Rebase detection and reading (git/client.rs):

    • read_rebase(): Detect and read rebase state from rebase-merge/ (interactive) or rebase-apply/ (am-backend) directories
    • apply_backend_pending(): Extract pending commits from numbered patch files
    • abbreviate_todo(): Batch-resolve full commit ids to short hashes for display
  • Display types (git/types.rs):

    • SeqKind enum: Categorizes commits (Pending, Stop, Done, Onto)
    • SeqStep struct: One row of rebase progress
    • RebaseInfo struct: Complete rebase state for display
  • UI rendering (ui/build.rs):

    • rebase_section(): Build the rebase-sequence section with color-coded step words
    • Integrated into status buffer, appearing before file lists
  • Todo parsing (git/todo.rs):

    • parse_todo_display(): Lenient parser for display (skips unsupported instructions like exec, break, label)
  • Theme (src/theme.rs):

    • Added sequence_stop, sequence_done, sequence_onto color roles for rebase step styling
  • Tests:

    • Unit tests for parsers and step assembly
    • Integration test verifying rebase progress display with a real conflicted rebase

Implementation notes

  • Rebase detection checks both rebase-merge/ (interactive) and rebase-apply/ (am-backend) directories
  • Commit ids are matched by prefix to handle both full and abbreviated hashes from different sources
  • The display is newest-first (like a log) so it reads top-to-bottom: pending, stop, done, base
  • Applied commits are detected via git log onto..HEAD to avoid relying on sequencer state files
  • The "onto" base is named after the branch it points to (via git name-rev) when possible, falling back to its short hash

https://claude.ai/code/session_014zsTaZna79VjjCAddF8BT1

claude added 3 commits July 26, 2026 16:34
While a rebase is underway the status buffer now shows Magit's
rebase-sequence section ("Rebasing topic onto main"): the remaining
todo lines, the commit the rebase stopped at, the commits already
applied, and the base — newest first, read like a log. Every row is a
Commit section, so RET shows the commit and the cursor sticks to it
across refreshes.

- StatusSnapshot grows rebase: Option<RebaseInfo>; the sequencer state
  is read from rebase-merge/ (and rebase-apply/ for the am backend,
  parsing the mailbox patch files) plus a few small git reads that only
  run mid-rebase. Full ids from the sequencer's files are abbreviated
  through one batched no-walk log.
- Step assembly is a pure function (parse.rs) unit-tested for both stop
  shapes: a conflict (not yet applied, own row) and an edit (applied,
  marked in place among the done commits).
- New theme roles sequence-stop / sequence-done / sequence-onto; pending
  rows reuse todo-action, aligned like the todo editor.

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