Skip to content

Fix multi-file amend retargeting#13614

Draft
Byron wants to merge 1 commit intomasterfrom
fix/cannot-amend-multiple-files-12533
Draft

Fix multi-file amend retargeting#13614
Byron wants to merge 1 commit intomasterfrom
fix/cannot-amend-multiple-files-12533

Conversation

@Byron
Copy link
Copy Markdown
Collaborator

@Byron Byron commented May 3, 2026

Summary

Fixes #12533.

but amend can accept comma-separated file IDs, but it amended each selected file into the original target commit ID. Since each amend rewrites the target commit, the second selected file could fail because the branch no longer contained the original commit.

This PR updates the amend flow to carry the rewritten commit ID forward between selected files. It also aggregates JSON output into a single result for multi-file amend so --json and --json --status-after stay valid.

Tests

  • cargo test -p but --test but amend -- --nocapture
  • cargo test -p but --test but command::rub
  • cargo fmt --check --all
  • codex review --commit 1dfe294afb21690537f1e70c5c04bd9a71c3af1e

Disclosure

Created by Codex on behalf of Byron. Byron will review before this is ready to merge.

`but amend` accepted comma-separated file IDs, but each selected file was amended into the original commit ID. The first amend rewrote the target commit, so the second amend could fail because the branch no longer contained the original commit.

Track the rewritten commit ID returned by each amend and use it as the target for the next selected file. In JSON mode, aggregate the per-file rewrite results into one JSON document so `--json` and `--json --status-after` remain valid.

Add CLI regression coverage for multi-file amend, JSON status-after output, and a duplicate-file no-op after a successful amend.

Validation:
- cargo test -p but --test but amend -- --nocapture
- cargo test -p but --test but command::rub
- cargo fmt --check --all
@github-actions github-actions Bot added rust Pull requests that update Rust code CLI The command-line program `but` labels May 3, 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.

Cannot amend multiple files to a commit

2 participants