Fix erroneous err='' output in worktree rm

This commit is contained in:
2026-08-11 14:58:05 +01:00
parent 06891857e5
commit bf1e0f0d67

View File

@@ -136,6 +136,7 @@ Manage git worktrees by branch name."
wt_list=$(git worktree list --porcelain) wt_list=$(git worktree list --porcelain)
local failed=0 local failed=0
local wt_path local wt_path
local err
for branch in "${branches[@]}"; do for branch in "${branches[@]}"; do
wt_path=$(echo "$wt_list" | awk -v b="$branch" \ wt_path=$(echo "$wt_list" | awk -v b="$branch" \
'/^worktree /{ sub(/^worktree /, ""); p=$0 } /^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); if($0==b) print p }') '/^worktree /{ sub(/^worktree /, ""); p=$0 } /^branch refs\/heads\//{ sub(/^branch refs\/heads\//, ""); if($0==b) print p }')
@@ -152,7 +153,6 @@ Manage git worktrees by branch name."
fi fi
local -a rm_args=() local -a rm_args=()
(( force )) && rm_args+=(--force) (( force )) && rm_args+=(--force)
local err
if err=$(git worktree remove "${rm_args[@]}" "$wt_path" 2>&1); then if err=$(git worktree remove "${rm_args[@]}" "$wt_path" 2>&1); then
: :
elif [[ "$err" == *"working trees containing submodules"* ]]; then elif [[ "$err" == *"working trees containing submodules"* ]]; then