From d56979362a651471b281a5d3c02d6af7d7103e19 Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Thu, 31 Mar 2022 16:15:46 +0200 Subject: [PATCH] git:checkout-worktree: `s/REPO_DIR/WORKTREE_PATH/` --- .config/zsh/autoload/git/git-checkout-worktree | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.config/zsh/autoload/git/git-checkout-worktree b/.config/zsh/autoload/git/git-checkout-worktree index 3c11651..fc1c1cb 100755 --- a/.config/zsh/autoload/git/git-checkout-worktree +++ b/.config/zsh/autoload/git/git-checkout-worktree @@ -11,13 +11,13 @@ # TODO: If any conflicts arise, all further shells should be interactive instead # of looping forever. -local REPO_NAME REPO_DIR +local REPO_NAME WORKTREE_PATH REPO_NAME="${$(git rev-parse --show-toplevel):t}" || return -REPO_DIR="$(mktemp -d -p "" "worktree.XXX.$REPO_NAME.$1")" +WORKTREE_PATH="$(mktemp -d -p "" "worktree.XXX.$REPO_NAME.$1")" -git worktree add "$REPO_DIR" "$1" -[[ -e "$REPO_DIR" ]] || return 1 -pushd -q "$REPO_DIR" +git worktree add "$WORKTREE_PATH" "$1" +[[ -e "$WORKTREE_PATH" ]] || return 1 +pushd -q "$WORKTREE_PATH" # Start subshell "$SHELL" @@ -28,8 +28,8 @@ popd -q # Restart the subshell until every issue is resolved and the worktree is # removed -until [[ ! -e "$REPO_DIR" ]] || git worktree remove "$REPO_DIR"; do - pushd -q "$REPO_DIR" +until [[ ! -e "$WORKTREE_PATH" ]] || git worktree remove "$WORKTREE_PATH"; do + pushd -q "$WORKTREE_PATH" "$SHELL" errc=$? popd -q