Repository navigation
perf(list): cache push-remote URL and share local-branch scan with capture_refs - #2673
Merged
Merged
Conversation
…pture_refs `wt list statusline --claude-code` ran two avoidable git for-each-ref subprocesses per render (worktrunk#2672): 1. `for-each-ref %(push:remotename) refs/heads/<branch>` ran twice when no open PR matched: detect_github calls github_owner_repo_for_branch for the PR fetch, then detect_github_commit_checks calls it again for the branch fallback. Cache the resolved push URL on RepoCache keyed by branch name (mirrors the existing effective_remote_urls cache). 2. `for-each-ref refs/heads/` ran twice across phases: capture_refs scanned on the main thread, then a worker-thread Branch::upstream triggered the local-branch inventory scan. capture_refs now populates the RepoCache.local_branches OnceCell as a side-effect — every later capture_refs still scans fresh, so wt merge's post-update snapshot semantics are unaffected. Closes #2672 Co-Authored-By: Claude <[email protected]>
Merged
max-sixty
added a commit
that referenced
this pull request
May 13, 2026
Release v0.50.0. Highlights: - Experimental Azure DevOps support (#1256, thanks @mikeyroush; fixes #1144 from @dlecan) — `wt switch pr:<N>`, `wt list --full`, and `wt config show --full` recognize Azure DevOps via the `az` CLI. - Experimental Gitea CI-status detection (#2702) on top of the Gitea `pr:` shortcut (#1320, thanks @SjB). - Hooks now resolve `.config/wt.toml` from the worktree they act on — the primary-worktree fallback is gone, and `post-remove` reads the removed worktree's config (snapshotted before removal). Approval prompts collect hook commands from the same worktree. Breaking change for setups that relied on the primary-worktree fallback; the changelog entry has the recovery action. (#2690, #2703, #2714, #2717, #2701, #2708, #2727, #2736, #2748) - The `wt switch` picker's `alt-r` removal no longer runs unapproved project hooks (#2746) — the picker's removal path is now routed through `handle_remove_output` and consults the existing approval state read-only. - `wt config alias show` with no name lists every alias's full definition (#2684, #2691); `wt --help` switches to a compact aliases pointer (#2688). - `wt list --branches` warm-run perf: SHA-keyed cache for `main↕` and `Remote⇅` ahead/behind counts; shared push-remote URL and local-branch scan (#2704, #2718, #2673). - Claude Code plugin ships the `wt-switch-create` skill (#2737, thanks @onetom for #2631). See `CHANGELOG.md` for the full list (8 Improved, 5 Fixed, 5 Internal). semver-checks reports breaking library-API changes (new enum variants without `#[non_exhaustive]`, removed `Branch::github_push_url`, new trait method on `RemoteRefProvider`), which mandates at minimum a minor bump pre-1.0.
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.
Problem
wt-perf cache-checkagainstwt list statusline --claude-codereported two same-context gitfor-each-refduplicates per render (#2672), one in the per-branch CI-status fan-out and one across the skeleton/slow phases.Root cause
for-each-ref %(push:remotename) refs/heads/<branch>ran twice for the same branch when no open PR matched.Branch::push_remote_url(the only call site ofgithub_push_url) had no cache:detect_githubcallsgithub_owner_repo_for_branchfor the PR fetch, and when that returns no matchdetect_cifalls through todetect_github_commit_checks, which calls it again.for-each-ref refs/heads/with the local-branch format ran twice across phases.populate_item(the statusline path's blocking entry point) callscapture_refs_with_ahead_behindon the main thread, which scansrefs/heads/independently ofRepoCache.local_branches. A worker thread then runsUpstreamTask, which callsBranch::upstream→Repository::local_branch→ first scan of the (still-empty) inventory cache.Solution
Branch::push_remote_urlonRepoCache.push_remote_urlskeyed by branch name (mirrors the existingeffective_remote_urlsDashMappattern).RefSnapshot::scan_localspopulateRepoCache.local_branchesas a side-effect —OnceCell::setis a no-op once populated, so subsequentcapture_refscalls still scan fresh and mutating commands likewt merge's post-update snapshot inworktree::finishkeep their fresh-snapshot semantics.Testing
capture_refs_populates_local_branch_cacheandcapture_refs_scans_fresh_when_cache_already_populateddocument both sides of the invariant — the side-effect populates the cache, but a latercapture_refsreading post-mutation refs still sees the new SHA.test_github_push_url_is_cachedremovesbranch.<name>.remotebetween calls and asserts the cached URL persists.cargo test --lib --bins(1109 + 643 unit) andcargo test --test integration(1637) pass.wt-perf cache-checkrecipe from the issue againstRUST_LOG=debug ./target/release/wt list statusline --claude-code—extra_calls: 0,same_context_duplicates: [](wasextra_calls: 2).Closes #2672 — automated triage