@@ -70,15 +70,17 @@ resolve_base_dir() {
7070
7171 # Canonicalize base_dir if it exists
7272 if [ -d " $base_dir " ]; then
73- local canonical_base=" $( canonicalize_path " $base_dir " ) "
73+ local canonical_base
74+ canonical_base=$( canonicalize_path " $base_dir " )
7475 if [ -n " $canonical_base " ]; then
7576 base_dir=" $canonical_base "
7677 fi
7778 # If canonicalization fails (empty result), base_dir keeps its absolute form
7879 fi
7980
8081 # Canonicalize repo_root before comparison
81- local canonical_repo_root=" $( canonicalize_path " $repo_root " ) "
82+ local canonical_repo_root
83+ canonical_repo_root=$( canonicalize_path " $repo_root " )
8284 # Warn if canonicalization fails (indicates repository issue)
8385 if [ -z " $canonical_repo_root " ]; then
8486 log_warn " Unable to canonicalize repository path: $repo_root "
@@ -89,8 +91,8 @@ resolve_base_dir() {
8991 if [[ " $base_dir " == " $canonical_repo_root " /* ]]; then
9092 local rel_path=" ${base_dir# $canonical_repo_root / } "
9193 # Check if .gitignore exists and whether it includes the worktree directory
92- if [ -f " $repo_root /.gitignore" ]; then
93- if ! grep -qE " ^/?${rel_path} /?\$ |^/?${rel_path} /\*?\$ " " $repo_root /.gitignore" 2> /dev/null; then
94+ if [ -f " $canonical_repo_root /.gitignore" ]; then
95+ if ! grep -qE " ^/?${rel_path} /?\$ |^/?${rel_path} /\*?\$ " " $canonical_repo_root /.gitignore" 2> /dev/null; then
9496 log_warn " Worktrees are inside repository at: $rel_path "
9597 log_warn " Consider adding '/$rel_path /' to .gitignore to avoid committing worktrees"
9698 fi
0 commit comments