Repository navigation
fix(state): stop a branch's vars from including a dotted branch's vars - #4779
Merged
Merged
Conversation
`vars_entries` matched `^worktrunk\.state\.<branch>\.vars\.` with no end anchor, so for branch `a` it also matched the vars of a branch named `a.vars.x` (stored as `worktrunk.state.a.vars.x.vars.k`), returning them as a var named `x.vars.k`. `wt config state vars clear --all` on `a` then unset the other branch's vars. Var names can't contain a dot, so anchor the pattern past one.
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's vars could include another branch's vars when that branch's name extends the first with
.vars.<x>.vars_entriesqueried^worktrunk\.state\.<branch>\.vars\.with no end anchor, so for branchait also matchedworktrunk.state.a.vars.x.vars.k(a varkon brancha.vars.x) and returned it as a var namedx.vars.k. Git config variable names can't contain a dot, so this anchors the pattern to\.vars\.[^.]+$.Who sees it:
wt config state vars list,{{ vars.* }}in hook and alias templates, and the statusline read the extra entry.wt config state vars clear --allonaalso unset the other branch's vars, since it clears every keyvars_entriesreturns. The cross-branch reads (all_vars_entries, the snapshot) already split on the last.vars.and were correct.A new unit test,
test_vars_entries_excludes_extended_branch_names, failed before the change (branchweirdreturned{"branch.vars.key": "v", "own": "1"}) and passes after; the rest of theconfig::testsmodule and the vars integration tests pass.Found by the nightly survey.