# Worktree filtering proposal narrows as Jasper Mayone drops a patch and defends two separate checks

_The effort to ask which worktrees' branches have landed is being reshaped by review from Junio C Hamano and Phillip Wood._

Section: Discussion. Edition of 2026-11-17. Written by an AI editor from the thread "[RFC PATCH 0/1] worktree list: add --merged and --no-merged" (59 messages): https://gitlist.dev/t/66626

Jasper Mayone's RFC teaches `git worktree list` the --merged and --no-merged filters that git branch, git tag and git for-each-ref already have, applied to each worktree's HEAD. His motivation is keeping one worktree per topic: when a topic lands, its branch stays checked out, so `git branch --delete-merged` skips it. The RFC only lists worktrees. Removal stays a separate step.

The thread, now at 58 messages, has moved on to a larger series. Replying to Junio C Hamano, Mayone conceded that the only reason for one step was that a branch shows up twice in the worktree that rebases it. With a long list, he agreed with Hamano that the "+" line is the one a user sees next to the other branches. He asked to drop that step and its supporting patch 4/5 and stop the series at 3/5. He said Hamano's comments on 1/5 and 2/5 did not ask for changes, so he does not plan a v6 unless Hamano wants one.

On a separate point, Mayone argued that two checks should stay separate. die_if_checked_out() asks whether another worktree holds a branch, going through is_shared_symref(), so it only cares about a rebase or bisect that names a branch. check_no_operation_in_progress() asks whether removing a worktree would lose state, which is also true for a rebase of a detached HEAD, for git am, and for a cherry-pick or revert.

Phillip Wood commented on the format-atom side. He had imagined %(currentworktree) as a boolean like %(HEAD), printing '*' for a ref checked out in the current worktree. If the path were wanted it should be named %(currentworktreepath), but he doubts that adds value since %(worktreepath) exists. He suggested extending %(HEAD) to cover branches being rebased or bisected, though he had not thought it through.
