diff --git a/scripts/dev/agent.sh b/scripts/dev/agent.sh index ae79daf..4501974 100755 --- a/scripts/dev/agent.sh +++ b/scripts/dev/agent.sh @@ -36,22 +36,18 @@ require_clean_tree() { [ -z "$dirty" ] || prefail "working tree is not clean — stash or commit first" } -worktree_count() { - # count registered worktrees that are NOT the main checkout +worktree_paths() { + # list worktree paths (excluding main); || true prevents grep exit-1 when empty local main_path main_path=$(git rev-parse --show-toplevel) git worktree list --porcelain \ | awk '/^worktree /{p=$2} /^$/{print p}' \ - | grep -cv "^${main_path}$" + | grep -v "^${main_path}$" \ + || true } -worktree_paths() { - # list worktree paths (excluding main) - local main_path - main_path=$(git rev-parse --show-toplevel) - git worktree list --porcelain \ - | awk '/^worktree /{p=$2} /^$/{print p}' \ - | grep -v "^${main_path}$" +worktree_count() { + worktree_paths | wc -l } branch_exists_local() { git show-ref --verify --quiet "refs/heads/$1"; }