feat: wt list --porcelain + [unadopted] indicator#35
Open
bezhermoso wants to merge 8 commits intoblock:mainfrom
Open
feat: wt list --porcelain + [unadopted] indicator#35bezhermoso wants to merge 8 commits intoblock:mainfrom
wt list --porcelain + [unadopted] indicator#35bezhermoso wants to merge 8 commits intoblock:mainfrom
Conversation
Adds a new library function that wraps `git worktree list --porcelain` and appends wt-specific metadata lines per entry: - wt.active — worktree is the WT_ACTIVE_WORKTREE symlink target - wt.adopted — adoption marker exists - wt.dirty, wt.ahead, wt.behind — with --verbose flag Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
Exposes the augmented porcelain output via `wt list --porcelain`. Combinable with -v for verbose metadata (dirty, ahead/behind). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
Unit tests for wt_list_porcelain() covering wt.active, wt.adopted, wt.dirty, wt.ahead indicators and verbose/non-verbose modes. Integration tests for wt-list --porcelain flag including color code absence check. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
Non-adopted worktrees now show a yellow ? prefix and [unadopted] badge. If the worktree is both linked and unadopted, the badge escalates to red to signal that the active worktree is missing metadata/symlinks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
Applies the same ? prefix and [unadopted] badge (yellow/red) to the interactive worktree selection menu used by wt switch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
Add missing guard on cd failure when iterating worktrees, matching the existing pattern in wt-list. Stale worktree registrations (directory removed but still in git's list) are now silently skipped instead of producing a warning and a blank entry in the picker. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
Only the * prefix for active/linked worktrees remains. The [unadopted] badge is sufficient on its own. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Claude Code <noreply@anthropic.com> Ai-assisted: true
wt list --porcelain + [unadopted] indicator
guodong-sq
reviewed
Mar 21, 2026
Collaborator
guodong-sq
left a comment
There was a problem hiding this comment.
this adds a new public --porcelain flag to wt list, but the bash/zsh completion definitions do not appear to advertise it yet. It would be good to update completions so the new flag is discoverable from both wt-list and unified wt list completion paths.
(same with the help text)
- wt-list: validate WT_MAIN_REPO_ROOT exists and is a git repo before dispatching to porcelain mode, so porcelain no longer returns an empty successful listing when the config points at a non-repo. - wt-choose: use pwd -P when deriving main_repo_abs so it compares equal to worktree entries (which also use pwd -P) when the configured path contains symlink components. Prevents the main repo from being mis-flagged as [unadopted]. - wt-choose: use wt_source helper to load wt-adopt. - completions + help: expose --porcelain in bash/zsh completion and in wt help output. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Contributor
Author
|
Re: the completions + help text feedback on the review — added in 04e2c4d:
|
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.
wt list --porcelain: machine-readable worktree metadata + new indicatorsSummary
wt list --porcelain— augmentedgit worktree list --porcelainwith wt-specific metadata lines[unadopted]indicator — surfaces unadopted worktrees inwt listandwt switchpicker--porcelainoutputPasses through native git porcelain verbatim and appends
wt.*lines per entry:With
-v, adds status metadata (slower — runsgit statusper worktree):wt.activeWT_ACTIVE_WORKTREEsymlinkwt.adoptedwt.dirty-vwt.ahead N-vwt.behind N-vWhat
--porcelainunlocksThe structured output makes wt data composable with unix tools and custom scripts. Examples:
Custom fzf worktree picker:
Shell completions that show adoption status:
Scripted batch adoption:
[unadopted]indicator in nice outputWorktrees not managed by wt now show
[unadopted]inwt listand thewt switchpicker. Color escalates based on severity:[unadopted]— informational: worktree exists but isn't wt-managed[unadopted]— when combined with[linked]: you're actively working in an unmanaged worktreeFixes
cd: No such file or directorywarnings or blank entries in thewt switchpicker. They are silently skipped, matching the existing behavior inwt list.Test plan
wt_list_porcelain()(wt.active, wt.adopted, wt.dirty, wt.ahead, verbose/non-verbose modes)wt list --porcelain(output format, color absence, flag combinations)[unadopted]indicator (adopted/unadopted/main/linked+unadopted)wt list --porcelainon a real repo with multiple worktreeswt listand verify[unadopted]appears on correct entrieswt switchand verify picker shows[unadopted]badges🤖 Generated with Claude Code