Repository navigation
refactor: wt list — status opt-in, fast by default - #9
Merged
Merged
Conversation
Default `wt list` now spawns exactly one git subprocess
(`git worktree list --porcelain`) regardless of worktree count — output is
Name/Branch/Path only. Pass `--status` for the dashboard view, which forks
`git status --porcelain` and `git rev-list --count @{u}..HEAD` per worktree
under a bounded worker pool (min(NumCPU, 8)). 5.5s → ≤100ms on a 25-worktree
repo for the default path; ≤1s under --status.
- Replace 3-call checkDirty with single `git status --porcelain`
- Replace 2-call getUnpushedInDir with single `git rev-list --count @{u}..HEAD`
- Split listEntries into Basic (zero per-wt forks) and Enriched (parallel)
- Switch listEntry.Dirty/Unpushed to *bool/*int so omitempty distinguishes
"not computed" (key absent) from "computed and clean/0" (key present)
- Reject --status + --path with ExitInvalidArgs
- Split tests into default-mode and --status-mode coverage; add 6 new tests
(--status flag, header, dirty, unpushed, JSON shape, ordering, mutex)
- Update docs/specs/cli-surface.md and README sample output
- Add docs/memory/wt-cli/list-status-contract.md
There was a problem hiding this comment.
Pull request overview
Refactors wt list to make per-worktree status enrichment opt-in via a new --status flag. The default path now performs a single git worktree list --porcelain invocation regardless of worktree count, reducing wall time from O(N forks) to O(1). When --status is set, enrichment runs in parallel via a bounded worker pool, and the per-worktree work itself is collapsed (git status --porcelain replaces the 3-call dirty check; git rev-list --count @{u}..HEAD replaces the 2-call upstream lookup).
Changes:
- Drop
Statuscolumn from default output; emit Name/Branch/Path only. JSON omitsdirty/unpushedkeys via*bool/*int+omitemptyso consumers can distinguish "not computed" from "clean". - New
--statusflag (mutually exclusive with--path) runs enrichment in a worker pool ofmin(NumCPU, 8)while preserving porcelain ordering through indexed slice writes. - Collapse
checkDirtyandgetUnpushedInDirto single git invocations each.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/cmd/wt/list.go | Splits getEnrichedEntries into basic/enriched paths, adds --status flag and worker pool, swaps multi-call git helpers for single-call ones, pointer-field JSON shape. |
| src/cmd/wt/list_test.go | Splits tests into default-mode and --status-mode; adds coverage for flag presence, exclusivity, unpushed marker, parallel ordering, JSON shapes. |
| README.md | Updates sample output and command-reference row to reflect new default. |
| docs/specs/cli-surface.md | Documents --status flag, mutex rules, default-output column set. |
| docs/memory/wt-cli/list-status-contract.md | New memory file capturing post-change invariants. |
| docs/memory/index.md | Indexes the new memory file. |
| fab/changes/260516-lfa8-list-status-opt-in/* | Fab pipeline artifacts (intake/spec/plan/status). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Meta
Pipeline: intake ✓ → spec ✓ → apply ✓ → review ✓ → hydrate ✓ → ship → review-pr
Impact: +389/−138 code (excluding
fab/,docs/) · +1004/−188 totalSummary
wt listwas paying for a dashboard view by default — forking up to 5gitsubprocesses per worktree (3 for dirty, 2 for unpushed). On a 25-worktree repo that meant ~125 forks and 5.5s wall time, scaling linearly with worktree count — exactly the wrong gradient for a discovery command meant to encourage cheap worktree usage. Status enrichment is now opt-in via--status; the default path runs exactly onegit worktree list --porcelaininvocation regardless of worktree count, targeting ≤100ms wall time.Changes
wt listoutput drops the Status column. Three-column table: Name / Branch / Path. Zero per-worktree git invocations.--statusflag opts back into dirty/unpushed enrichment. Parallel worker pool ofmin(runtime.NumCPU(), 8); output ordering preserved.--status:git status --porcelainreplaces the 3-callcheckDirty;git rev-list --count @{u}..HEADreplaces the 2-callgetUnpushedInDir(uses@{u}shorthand, drops separaterev-parse).Dirty/Unpushedare now*bool/*intwithomitempty. Default mode omits the keys entirely;--statusalways emits them — so consumers can distinguish "not computed" from "computed and clean".--status+--pathrejects withExitInvalidArgs.--status+--jsonis permitted.--status-mode coverage. 9 new tests: flag presence, headers, dirty marker, unpushed marker (↑2), JSON shape, ordering under parallelism, mutex.docs/specs/cli-surface.mdupdated; new memory filedocs/memory/wt-cli/list-status-contract.mdcaptures the post-change invariants; README sample output and command-reference updated.Test plan
go vet ./src/...cleango test ./src/cmd/wt/... -run TestList -count=1→ 25/25 PASSgo test -race ./src/cmd/wt/... -run "TestList_Status.*"→ PASS (no data races in worker pool)go test ./src/cmd/wt/... -run TestIntegration -count=1→ 12/12 PASS (unchanged integration tests)wt liston a 25+ worktree repo confirms sub-100ms wall time (recommended)wt list --statuson same repo confirms dashboard view returns under 1s