mirror of
https://github.com/harivansh-afk/nix.git
synced 2026-04-15 10:05:17 +00:00
Fix worktree path resolution inside linked worktrees
Resolve the path anchor from the repository common git dir so running wtc from inside an existing worktree still names sibling worktrees from the main checkout root. Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
parent
8ad1784a82
commit
9f1f4f04dd
1 changed files with 6 additions and 1 deletions
|
|
@ -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')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue