Skip to content

commit squash: use merge arithmetic#13873

Merged
estib-vega merged 1 commit into
masterfrom
merge-arithmetic-squash
May 21, 2026
Merged

commit squash: use merge arithmetic#13873
estib-vega merged 1 commit into
masterfrom
merge-arithmetic-squash

Conversation

@estib-vega
Copy link
Copy Markdown
Contributor

@estib-vega estib-vega commented May 18, 2026

Use merge arithmetic instead of reordering the commits for a faster,
more reliable squash.


This is part 2 of 3 in a stack made with GitButler:

@github-actions github-actions Bot added the rust Pull requests that update Rust code label May 18, 2026
@estib-vega estib-vega force-pushed the merge-changes-into-tree branch from c2adc8b to 7dbbe8c Compare May 18, 2026 13:59
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from fe04f31 to 5f357ce Compare May 18, 2026 13:59
@estib-vega estib-vega force-pushed the merge-changes-into-tree branch from 7dbbe8c to 2ac95fb Compare May 19, 2026 07:33
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from 5f357ce to f7f376b Compare May 19, 2026 07:33
@estib-vega estib-vega force-pushed the merge-changes-into-tree branch from 2ac95fb to cc90fcf Compare May 19, 2026 07:45
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from f7f376b to cb68058 Compare May 19, 2026 07:46
@estib-vega estib-vega force-pushed the merge-changes-into-tree branch from cc90fcf to 26cf8ca Compare May 19, 2026 07:55
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from cb68058 to bd552d4 Compare May 19, 2026 07:56
@estib-vega estib-vega marked this pull request as ready for review May 20, 2026 07:15
Copilot AI review requested due to automatic review settings May 20, 2026 07:15
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the workspace commit-squash implementation to compute the squashed tree via merge arithmetic (merging only the selected commits’ change ranges) rather than reordering commits around the target, aiming for faster and more reliable squashes.

Changes:

  • Replaces the “reorder then squash” approach with merge_commit_changes_to_tree to derive the squashed tree and fails early on merge conflicts.
  • Updates an existing squash-conflict test to assert the new error behavior/message.
  • Adds a new workspace scenario + test ensuring cross-stack squashes don’t accidentally pull in unselected ancestor tree state.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/but-workspace/src/commit/squash_commits.rs Switches squash to merge-arithmetic tree construction, removes reordering logic, and rewrites graph steps to drop subject commits and replace the target.
crates/but-workspace/tests/workspace/commit/squash_commits.rs Updates conflict expectation and adds a regression test for cross-stack squashes not pulling in unselected ancestor state.
crates/but-workspace/tests/fixtures/scenario/ws-ref-ws-commit-single-stack-double-stack-files.sh Adds a new fixture repository topology used by the new regression test.

Comment thread crates/but-workspace/src/commit/squash_commits.rs
Comment thread crates/but-workspace/src/commit/squash_commits.rs
@estib-vega estib-vega force-pushed the merge-changes-into-tree branch from 26cf8ca to e550b59 Compare May 20, 2026 07:39
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from bd552d4 to 5cc953b Compare May 20, 2026 07:39
Copilot AI review requested due to automatic review settings May 20, 2026 07:54
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from 5cc953b to 386657d Compare May 20, 2026 07:54
@github-actions github-actions Bot added the CLI The command-line program `but` label May 20, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread crates/but-workspace/src/commit/squash_commits.rs
Use merge arithmetic instead of reordering the commits for a faster,
more reliable squash.
@estib-vega estib-vega force-pushed the merge-changes-into-tree branch from e550b59 to 3be8ea6 Compare May 20, 2026 16:01
@estib-vega estib-vega force-pushed the merge-arithmetic-squash branch from 386657d to 75fda44 Compare May 20, 2026 16:01
Base automatically changed from merge-changes-into-tree to master May 21, 2026 07:09
@estib-vega estib-vega merged commit cad541e into master May 21, 2026
36 checks passed
@estib-vega estib-vega deleted the merge-arithmetic-squash branch May 21, 2026 07:09
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.

3 participants