From d5a95f9ce55a77f4a0345557cd300317894dc629 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Mon, 15 Sep 2025 13:19:28 +0200 Subject: [PATCH] git:cow: Fix name of submodules Previously git-checkout-worktree would use the name of the superproject instead of the submodule for the temporary directory. --- .config/zsh/autoload/git/git-checkout-worktree | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.config/zsh/autoload/git/git-checkout-worktree b/.config/zsh/autoload/git/git-checkout-worktree index 746d50d..04cce00 100755 --- a/.config/zsh/autoload/git/git-checkout-worktree +++ b/.config/zsh/autoload/git/git-checkout-worktree @@ -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