commit squash: use merge arithmetic#13873
Merged
Merged
Conversation
c2adc8b to
7dbbe8c
Compare
fe04f31 to
5f357ce
Compare
7dbbe8c to
2ac95fb
Compare
5f357ce to
f7f376b
Compare
2ac95fb to
cc90fcf
Compare
f7f376b to
cb68058
Compare
cc90fcf to
26cf8ca
Compare
cb68058 to
bd552d4
Compare
Contributor
There was a problem hiding this comment.
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_treeto 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. |
26cf8ca to
e550b59
Compare
bd552d4 to
5cc953b
Compare
5cc953b to
386657d
Compare
Caleb-T-Owens
approved these changes
May 20, 2026
Use merge arithmetic instead of reordering the commits for a faster, more reliable squash.
e550b59 to
3be8ea6
Compare
386657d to
75fda44
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: