diff --git a/scripts/wt-path.sh b/scripts/wt-path.sh index 46e4b62..9d8abb9 100644 --- a/scripts/wt-path.sh +++ b/scripts/wt-path.sh @@ -7,11 +7,16 @@ if [[ $# -ne 1 ]]; then exit 1 fi -repo_root=$(git rev-parse --show-toplevel 2>/dev/null) || { +common_git_dir=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) || { printf 'wt-path: not inside a git repository\n' >&2 exit 1 } +repo_root=$(cd "${common_git_dir}/.." && pwd -P) || { + printf 'wt-path: failed to resolve repository root\n' >&2 + exit 1 +} + worktree_name=$1 clean_name=$(printf '%s' "$worktree_name" | sed -E 's#[^[:alnum:]._-]+#-#g; s#-+#-#g; s#(^[.-]+|[.-]+$)##g')