Repository navigation
fix(switch): clear a stale marker when --create makes the branch - #4704
Merged
Merged
Conversation
A branch deleted outside wt (git branch -D) leaves worktrunk.state.<branch>.marker behind, and a later `wt switch --create` with the same name showed the old marker. Clear it when --create succeeds, reusing #4684's deletion helper, now Repository::clear_branch_marker. A branch deleted and recreated with plain git still keeps its marker until `wt config state marker clear`. Refs #4683
1 task
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.
A branch deleted outside
wt(for example withgit branch -D) leaves itsworktrunk.state.<branch>.markerkey in git config. A laterwt switch --createwith the same name then showed the old 🤖/💬. Nowwt switch --createclears that branch's marker oncegit worktree add -bsucceeds. #4684 already clears the marker on everywtdeletion path. This is the follow-up the maintainer asked for when closing #4685.Repository::clear_branch_marker, and both call sites use it. It is still best effort: a failed unset is logged at debug level, and only marker JSON is removed, so avarsentry namedmarkerthat shares the key is left alone.--createclears the marker. Switching to an existing branch keeps its marker, and so does a DWIM checkout from a remote branch or a PR/MR ref.gitstill keeps its marker untilwt config state marker clear. The marker help, its generated docs, and the help snapshot now say so.test_switch_create_clears_stale_markersets a marker on a branch name that has no branch and on an existing branch. It then runswt switch --createfor the first and plainwt switchfor the second. It fails without the change, because the stale marker survives, and passes with it. The existingdeletion_*unit tests pass on the moved helper.Refs #4683