Skip to content

Fix but amend with multiple sources by refreshing rewritten commit target#12541

Draft
Copilot wants to merge 3 commits intomasterfrom
copilot/add-test-and-fix-issue-12533
Draft

Fix but amend with multiple sources by refreshing rewritten commit target#12541
Copilot wants to merge 3 commits intomasterfrom
copilot/add-test-and-fix-issue-12533

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

but amend <source1,source2,...> <commit> was applying the first source, rewriting the commit, then trying to amend the remaining sources into the stale pre-rewrite commit ID. This caused multi-file amend to fail mid-operation.

  • Regression coverage

    • Added amend_command_with_multiple_files in crates/but/tests/but/command/rub.rs.
    • Test stages two files, amends both into one commit via comma-separated source IDs, and asserts both changes are present in the resulting commit with no leftover assigned/unassigned changes.
  • Amend execution now returns rewritten commit ID

    • Updated crates/but/src/command/legacy/rub/amend.rs:
      • uncommitted_to_commit(...) -> anyhow::Result<Option<ObjectId>>
      • assignments_to_commit(...) -> anyhow::Result<Option<ObjectId>>
    • Both functions now return outcome.new_commit so callers can continue with the latest commit identity.
  • Rub operation pipeline propagates commit rewrites

    • Updated RubOperation::execute(...) in crates/but/src/command/legacy/rub/mod.rs to return Option<ObjectId>.
    • Amend paths return the new commit OID; non-amend paths return None.
    • handle(...) now updates the in-loop CliId::Commit target when an operation rewrites the commit, so subsequent sources amend into the current commit.
if let Some(new_commit) = operation.execute(ctx, out)? {
    if let CliId::Commit { id, .. } = target {
        target = CliId::Commit { commit_id: new_commit, id };
    }
}

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
gitbutler-web Ignored Ignored Preview Feb 23, 2026 11:35am

Request Review

Copilot AI and others added 2 commits February 23, 2026 11:31
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
Co-authored-by: Byron <63622+Byron@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test for issue 12533 and fix the related problem Fix but amend with multiple sources by refreshing rewritten commit target Feb 23, 2026
Copilot AI requested a review from Byron February 23, 2026 11:37
@github-actions github-actions bot added rust Pull requests that update Rust code CLI The command-line program `but` labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLI The command-line program `but` rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants