git🐮 Fix name of submodules

Previously git-checkout-worktree would use the name of the superproject
instead of the submodule for the temporary directory.
This commit is contained in:
2025-09-15 13:19:28 +02:00
parent 723899d70f
commit d5a95f9ce5

View File

@@ -31,10 +31,12 @@
emulate -L zsh -o err_return -o no_unset
local REPO_NAME WORKTREE_PATH
local git_dir REPO_NAME WORKTREE_PATH
# Use the folder name of the main working tree to make calls from another
# temporary working tree possible
REPO_NAME="${${${$(git rev-parse --git-dir):A}%%/.git*}:t}"
git_dir="${$(git rev-parse --git-dir):A}"
[[ $git_dir == */.git/modules/* ]] || git_dir="${git_dir%%/.git*}"
REPO_NAME="${git_dir:t}"
WORKTREE_PATH="$(mktemp -d -p "" "worktree.XXX.$REPO_NAME.${1//\//_}")"
local errc ret=0