Repository navigation
fix(merge): use branch name as-is in safety backup ref - #2463
Merged
Merged
Conversation
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>
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.
Problem
WorkingTree::create_safety_backup()flattened/to-in the ref path, so distinct branches likea/banda-bcollided at the samerefs/wt-backup/a-bref. The latest backup for one branch could clobber the other, the reflog mixed entries from unrelated branches, and the documentedrefs/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/foois fine — so the branch name can be used directly. The user-facing docs (mergehelp text,merge.md) already sayrefs/wt-backup/<branch>; this aligns the code with what the docs describe.Testing
Added a unit test in
working_tree.rsthat creates safety backups on botha/banda-b, then asserts both refs (refs/wt-backup/a/bandrefs/wt-backup/a-b) coexist. Verified the test fails onmainand passes with the fix. Existingtest_merge_squash_with_working_tree_creates_backupstill passes.Closes #2459 — automated triage