Repository navigation
fix(git): harden worktree add in main-worktree relocate against hyphen-prefixed branches - #2738
Merged
Merged
Conversation
…hen-prefixed branches Follow-up to #2725. The hardening sweep missed the `git worktree add` call in `move_main_worktree` — `worktree` wasn't in the subcommand list, but the same `-foo`-as-flag hazard applies. A branch named `-foo` (creatable via `git update-ref refs/heads/-foo HEAD`) on the main worktree would crash `wt step relocate` with `unknown switch 'o'`. Adds `--end-of-options` before the path and branch positionals, matching the convention documented in `Repository::run_command`. Also adds a regression test that fails without the fix.
Merged
max-sixty
added a commit
that referenced
this pull request
May 13, 2026
Per @worktrunk-bot review: #2738 is a follow-up to #2725 that hardens `git worktree add` in `move_main_worktree` against hyphen-prefixed branches. It merged to main before this release PR, so it ships in 0.50.0 — add it to the bullet's PR list and note the `wt step relocate` site.
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.
Follow-up to #2725. The hyphen-prefixed-ref hardening sweep missed the
git worktree addcall inmove_main_worktree. A branch literally named-foo(creatable viagit update-ref refs/heads/-foo HEAD) on the main worktree would crashwt step relocatewithgit worktree add: unknown switch 'o'.Adds
--end-of-optionsbefore the path and branch positionals, matching the convention documented inRepository::run_commandand used throughout the codebase after #2725. Also adds a regression test that fails without the fix (verified locally — without--end-of-options,wt step relocateexits non-zero with git's "unknown switch" error).Test plan
cargo test --test integration test_relocate— all 23 relocate tests passunknown switch 'o'cargo clippy --all-targets -- -D warnings— clean