Skip to content

Commit a2c7c5b

Browse files
iamaeroplaneclaude
andcommitted
fix: check git command exists before calling get_repo_root in has_git
Avoids unnecessary work when git isn't installed since get_repo_root may internally call git rev-parse. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 43b3d55 commit a2c7c5b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

scripts/bash/common.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ get_current_branch() {
9494
# Returns true only if git is installed and the repo root is inside a git work tree
9595
# Handles both regular repos (.git directory) and worktrees/submodules (.git file)
9696
has_git() {
97-
local repo_root=$(get_repo_root)
98-
# First check if git command is available
97+
# First check if git command is available (before calling get_repo_root which may use git)
9998
command -v git >/dev/null 2>&1 || return 1
99+
local repo_root=$(get_repo_root)
100100
# Check if .git exists (directory or file for worktrees/submodules)
101101
[ -e "$repo_root/.git" ] || return 1
102102
# Verify it's actually a valid git work tree

0 commit comments

Comments
 (0)