git:checkout-worktree: Improve name on recursion

When calling git-checkout-worktree from inside a temporary working tree
(doesn't necessary need to be a recursive call, could be another shell
too) the name would be very long.

Fix this by using the folder name of the main working tree.
This commit is contained in:
2023-04-11 23:24:52 +02:00
parent 072204c10c
commit 5deb69bbd6

View File

@@ -27,7 +27,9 @@
emulate -L zsh -o err_return -o no_unset
local REPO_NAME WORKTREE_PATH
REPO_NAME="${$(git rev-parse --show-toplevel):t}"
# 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}"
WORKTREE_PATH="$(mktemp -d -p "" "worktree.XXX.$REPO_NAME.${1//\//_}")"
local errc ret=0