Skip to content

fix(state): stop a branch's vars from including a dotted branch's vars - #4779

Merged
max-sixty merged 1 commit into
mainfrom
nightly/clean-43378608288
Nov 13, 2026
Merged

max-sixty merged 1 commit into
mainfrom
nightly/clean-43378608288

Conversation

@worktrunk-bot

Copy link
Copy Markdown
Collaborator

A branch's vars could include another branch's vars when that branch's name extends the first with .vars.<x>. vars_entries queried ^worktrunk\.state\.<branch>\.vars\. with no end anchor, so for branch a it also matched worktrunk.state.a.vars.x.vars.k (a var k on branch a.vars.x) and returned it as a var named x.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 --all on a also unset the other branch's vars, since it clears every key vars_entries returns. 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 (branch weird returned {"branch.vars.key": "v", "own": "1"}) and passes after; the rest of the config::tests module and the vars integration tests pass.

Found by the nightly survey.

`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.
@worktrunk-bot worktrunk-bot added the nightly-cleanup Issues found by nightly code quality sweep label Nov 13, 2026
@max-sixty
max-sixty merged commit da09f17 into main Nov 13, 2026
36 of 45 checks passed
@max-sixty
max-sixty deleted the nightly/clean-43378608288 branch November 13, 2026 20:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nightly-cleanup Issues found by nightly code quality sweep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants