Skip to content

fix(commit,absorb): restore the staged patch before deleting the state file - #299

Open
narnaud wants to merge 1 commit into
mainfrom
fix-restore-before-delete
Open

narnaud wants to merge 1 commit into
mainfrom
fix-restore-before-delete

Conversation

@narnaud

@narnaud narnaud commented Sep 22, 2026

Copy link
Copy Markdown
Owner

drop, reword, swap, update and fold's rewriting paths put the saved
patch back on the Completed arm and delete their state file after, so a
delete that fails still leaves the index as the user had it. commit and
absorb kept the restore inside post_commit/post_absorb, which run after
the delete: a failed delete returned first and left the staged work unstaged,
where only loom continue would have put it back — on a command that had
just succeeded.

The restore moves to both call sites of each helper, the way update does
it, and the post_* helpers go back to reporting only. Fold's uncommit path
keeps the restore last and now says why: the apply it guards undoes itself by
diffing the working tree against the index.

Co-Authored-By: Claude Opus 5 (1M context) noreply@anthropic.com
Change-Id: I6a955eaa34655c124af7aaf45ab4ca2475d0deba

Summary by CodeRabbit

  • Bug Fixes

    • Improved preservation of staged changes when completing or resuming rebases.
    • Staged files and rewritten hunks are now restored safely before cleanup, including after conflict resolution and continue/abort workflows.
    • Failed cleanup operations no longer risk leaving the index in an incomplete state.
    • Non-HEAD uncommit workflows now maintain staged changes correctly while applying undo operations.
  • Documentation

    • Updated data-safety guidance to clarify staged-change restoration behavior across rebase and recovery workflows.

…e file

`drop`, `reword`, `swap`, `update` and fold's rewriting paths put the saved
patch back on the `Completed` arm and delete their state file after, so a
delete that fails still leaves the index as the user had it. `commit` and
`absorb` kept the restore inside `post_commit`/`post_absorb`, which run after
the delete: a failed delete returned first and left the staged work unstaged,
where only `loom continue` would have put it back — on a command that had
just succeeded.

The restore moves to both call sites of each helper, the way `update` does
it, and the `post_*` helpers go back to reporting only. Fold's uncommit path
keeps the restore last and now says why: the apply it guards undoes itself by
diffing the working tree against the index.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Change-Id: I6a955eaa34655c124af7aaf45ab4ca2475d0deba
@coderabbitai

coderabbitai Bot commented Sep 22, 2026

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 0807897f-8393-49da-97c3-f8d1726c7d75

📥 Commits

Reviewing files that changed from the base of the PR and between eb1aeac and 86d8b21.

📒 Files selected for processing (5)
  • CLAUDE.md
  • specs/014-continue-abort.md
  • src/absorb.rs
  • src/commit.rs
  • src/fold.rs

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

The change moves staged-change restoration before transaction deletion on completed and resumed rebase paths. Absorb and commit post-processing helpers no longer restore staged changes. Documentation records the fold uncommit exception and restoration behavior.

Changes

Staged restoration ordering

Layer / File(s) Summary
Restoration ordering contract
CLAUDE.md, specs/014-continue-abort.md, src/fold.rs
Documentation records restoration before transaction deletion, three-way application behavior, and the fold uncommit exception.
Rebase completion paths
src/absorb.rs, src/commit.rs
Completed and resumed rebase paths restore staged changes explicitly before cleanup or post-processing. post_absorb and post_commit no longer restore staged changes.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: dfaure-kdab

Merge Risk: ⚪ Minimal · up to 86d8b

No actionable merge-blocking risk remains in the staged-restoration ordering changes.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: restoring the staged patch before deleting the state file in commit and absorb.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 3 files. (2 skipped: 2 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant