From 5deb69bbd6bc8236828d832d9cbad2db38b40a28 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Tue, 11 Apr 2023 23:24:52 +0200 Subject: [PATCH] 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. --- .config/zsh/autoload/git/git-checkout-worktree | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/zsh/autoload/git/git-checkout-worktree b/.config/zsh/autoload/git/git-checkout-worktree index f297323..2893ec0 100755 --- a/.config/zsh/autoload/git/git-checkout-worktree +++ b/.config/zsh/autoload/git/git-checkout-worktree @@ -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