From 0c404f9544a0e6553a81c113938a9e7cc6f9a776 Mon Sep 17 00:00:00 2001 From: David Alley Date: Sun, 8 Feb 2026 16:41:44 -0600 Subject: [PATCH] fix(git-worktree): detect worktrees where .git is a file, not a directory (#159) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In git worktrees, .git is a regular file containing a gitdir: pointer back to the main repository — not a directory. The -d check caused list and cleanup to silently skip all worktrees, reporting "No worktrees found". Changed to -e (exists) which handles both cases. Fixes #158 Co-authored-by: Claude Opus 4.6 --- .../skills/git-worktree/scripts/worktree-manager.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/compound-engineering/skills/git-worktree/scripts/worktree-manager.sh b/plugins/compound-engineering/skills/git-worktree/scripts/worktree-manager.sh index 713c7fa..9a75334 100755 --- a/plugins/compound-engineering/skills/git-worktree/scripts/worktree-manager.sh +++ b/plugins/compound-engineering/skills/git-worktree/scripts/worktree-manager.sh @@ -134,7 +134,7 @@ list_worktrees() { local count=0 for worktree_path in "$WORKTREE_DIR"/*; do - if [[ -d "$worktree_path" && -d "$worktree_path/.git" ]]; then + if [[ -d "$worktree_path" && -e "$worktree_path/.git" ]]; then count=$((count + 1)) local worktree_name=$(basename "$worktree_path") local branch=$(git -C "$worktree_path" rev-parse --abbrev-ref HEAD 2>/dev/null || echo "unknown") @@ -231,7 +231,7 @@ cleanup_worktrees() { local to_remove=() for worktree_path in "$WORKTREE_DIR"/*; do - if [[ -d "$worktree_path" && -d "$worktree_path/.git" ]]; then + if [[ -d "$worktree_path" && -e "$worktree_path/.git" ]]; then local worktree_name=$(basename "$worktree_path") # Skip if current worktree