fix(git-clean): strip the '+' other-worktree marker too

git branch -vv marks column 1 with '+' (not '*') for a branch checked
out in another linked worktree. Only '*' was stripped from $1, so a
gone branch shown with '+' left a bogus "+" entry in $gone_branches
that then failed to delete: error: branch '+' not found.

Add a regression case reproducing the '+'-marked gone-branch line via
the existing git-clean mock handler in tests/test-network-fish.fish.
This commit is contained in:
2026-09-09 21:14:04 -04:00
parent d93cb286ef
commit e6c6d2533d
2 changed files with 31 additions and 1 deletions
+6 -1
View File
@@ -44,7 +44,12 @@ function git-clean --description 'Sync main, prune remotes, and delete orphaned
git fetch --prune --quiet
# 2. Identify orphaned branches and current branch
set -l gone_branches (git branch -vv | awk '/: gone\]/ {gsub(/\*/, ""); print $1}')
# git branch -vv marks column 1 with '*' for the current worktree's
# branch or '+' for a branch checked out in another linked worktree.
# Only '*' was stripped here, so a gone branch checked out elsewhere
# left its '+' glued onto $1, producing a bogus "+" entry that later
# failed to delete ("branch '+' not found").
set -l gone_branches (git branch -vv | awk '/: gone\]/ {sub(/^[*+]/, ""); print $1}')
set -l current_branch (git branch --show-current)
if test -n "$gone_branches"