Skip to content

fix(merge): use branch name as-is in safety backup ref - #2463

Merged
max-sixty merged 2 commits into
mainfrom
fix/issue-2459
Apr 29, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/issue-2459

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

Problem

WorkingTree::create_safety_backup() flattened / to - in the ref path, so distinct branches like a/b and a-b collided at the same refs/wt-backup/a-b ref. The latest backup for one branch could clobber the other, the reflog mixed entries from unrelated branches, and the documented refs/wt-backup/<branch> recovery path didn't match the actual ref name for slash branches.

Solution

Drop the replace('/', "-"). Slashes are valid in git ref names — update-ref refs/wt-backup/feature/foo is fine — so the branch name can be used directly. The user-facing docs (merge help text, merge.md) already say refs/wt-backup/<branch>; this aligns the code with what the docs describe.

Testing

Added a unit test in working_tree.rs that creates safety backups on both a/b and a-b, then asserts both refs (refs/wt-backup/a/b and refs/wt-backup/a-b) coexist. Verified the test fails on main and passes with the fix. Existing test_merge_squash_with_working_tree_creates_backup still passes.


Closes #2459 — automated triage

Slashes are valid in git ref names, so `branch.replace('/', "-")` was
unnecessary and caused branches like `a/b` and `a-b` to collide at the
same `refs/wt-backup/a-b` ref — letting one backup clobber the other and
mismatching the documented `refs/wt-backup/<branch>` recovery path.

Closes #2459

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 9ebcec0 into main Apr 29, 2026
24 checks passed
@max-sixty
max-sixty deleted the fix/issue-2459 branch April 29, 2026 19:07
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.

Safety backup refs collide for slash and dash branch names

2 participants