Re: [PATCH v2] worktree list: add --branch to select worktrees by branch
One further thought ...
On 25/10/2026 14:47, Phillip Wood wrote:
Show 12 quoted lines
> On 24/10/2026 17:53, Jasper Mayone wrote:
> >> For example, to list
>> the worktrees whose branch is merged into origin/main:
>>
>> git worktree list \
>> $(git branch --format='--branch=%(refname)' --merged origin/main)
>>
>> The --format is needed because the default output of "git branch"
>> marks the current branch with "*" and the branches checked out in
>> other worktrees with "+". It uses the full name because
>> %(refname:short) gives "heads/topic" when a tag is also called
>> "topic".
I think you can use "%(refname:lstrip=2)" to always remove "refs/heads/" which means we could simplify the implementation and just accept branch names.
Thanks
Phillip