Skip to content

refactor(repo): filter Branch::remotes() over the shared remote-branch inventory - #2371

Merged
max-sixty merged 1 commit into
mainfrom
branch-remotes-inventory
Apr 22, 2026
Merged

refactor(repo): filter Branch::remotes() over the shared remote-branch inventory#2371
max-sixty merged 1 commit into
mainfrom
branch-remotes-inventory

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

Drops the per-call git for-each-ref refs/remotes/*/<name> subprocess in Branch::remotes() and replaces it with an in-memory filter over Repository::remote_branches(). The inventory was introduced in #2368; this is follow-up #1 — the one accessor left outside the consolidation.

On wt switch <branch> for a remote-only branch, the old code spawned a duplicate refs/remotes/ scan after the inventory scan had already run. After this change there is one canonical for-each-ref refs/remotes/ per Repository, shared by every caller.

Behavioral note

When multiple remotes have the same branch, remotes()[0] now reflects the inventory's committer-timestamp-desc order rather than git's alphabetical default. The only affected sites are informational — the remote name shown in a warning at switch.rs:417 and the RemoteOnlyBranch error at repository_ext.rs:156. No correctness impact, and nearly all users have a single remote.

…h inventory

Drops the per-call `git for-each-ref refs/remotes/*/<name>` subprocess in
`Branch::remotes()` and replaces it with an in-memory filter over
`Repository::remote_branches()`. The inventory was introduced in #2368;
this is follow-up #1 — the one accessor left outside the consolidation.

On `wt switch <branch>` for a remote-only branch, the old code spawned a
duplicate `refs/remotes/` scan after the inventory scan had already run.
After this change there is one canonical `for-each-ref refs/remotes/` per
Repository, shared by every caller.

Minor behavioral nuance: when multiple remotes have the same branch,
`remotes()[0]` now reflects the inventory's committer-timestamp-desc
order rather than git's alphabetical default. The only affected sites
are informational (the remote name shown in a warning at
`switch.rs:417` and the `RemoteOnlyBranch` error at
`repository_ext.rs:156`) — no correctness impact, and nearly all users
have a single remote.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@max-sixty
max-sixty merged commit 712bc96 into main Apr 22, 2026
25 of 26 checks passed
@max-sixty
max-sixty deleted the branch-remotes-inventory branch April 22, 2026 02:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants