Repository navigation
feat(shell): take switch flags in the checkout wrapper, add --vanilla - #56
Merged
Merged
Conversation
`git checkout -q <branch>` used to bypass the wrapper because of the flag, so git refused with "already used by worktree". Flags that only change how a switch runs (-q, --progress, -m, -f, --discard-changes, --track, --guess, --recurse-submodules and their negations) are now set aside and passed to the switch the wrapper runs; they are dropped when it only cds into another worktree. Commands it hands to git keep their original arguments, so -b/-c/--detach/paths behave as before. `--vanilla` (before `--`) runs plain git minus the flag, for git's own behavior from gco/gsw; git rejects it too, so it fails safely if the wrapper isn't loaded. Co-Authored-By: Claude Opus 5.5 <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.
gco <branch> -q(or any flag) bypassed the checkout wrapper, so git refused withfatal: '<branch>' is already used by worktree. The wrapper only handled the baregit checkout <branch>form. There was also no short way to get git's own behavior fromgco/gsw, sincecommand gitdoesn't work with aliases.Flags that only change how a switch runs are now set aside and passed to the switch the wrapper runs:
-q/--quiet,--progress/--no-progress,-m/--merge,-f/--force,--discard-changes,-t/--track[=…]/--no-track,--guess/--no-guess,--recurse-submodules[=…]/--no-recurse-submodules. They're dropped when the wrapper onlycds into the worktree that has the branch, since nothing switches there. Anything that changes what checkout does (-b/-c/--orphan,--detach,-p,-, paths) still goes straight to git, with its original arguments in their original order.--vanillabefore--runs plain git minus the flag:gco --vanilla feat. Git rejects--vanillatoo, so it fails safely if the wrapper isn't loaded, the same reasoning as-..plainvsrestsplit ingit().rest(flags removed) decides whether the wrapper applies; every hand-off to git usesplain(original arguments minus-.).-freaches the switch wherever it happens. From a linked worktree,gco -f devforce-switches the main checkout and discards its local changes, as git's-fwould there.-qwith a branch held elsewhere, quiet switches in the main checkout and with-.,--vanillareproducing git's refusal,-band-q -bhand-off,-freaching the main checkout,-q -- <path>, and--vanillaas a path after--.🤖 Generated with Claude Code