From 02a0e17bcb1d11caec9a1577693e6cfc181ff99f Mon Sep 17 00:00:00 2001 From: Julian Prein Date: Thu, 31 Mar 2022 15:33:53 +0200 Subject: [PATCH] git:checkout-worktree: Fix exit when not in repo Fix the exit condition when the function is called outside of a git repository. Use zsh's `:t` History Expansion Modifier, as `$?` does not keep `git rev-parse`'s exit code, but rather `basename`'s. --- .config/zsh/autoload/git/git-checkout-worktree | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/zsh/autoload/git/git-checkout-worktree b/.config/zsh/autoload/git/git-checkout-worktree index 51f9e4b..9b5eaa4 100755 --- a/.config/zsh/autoload/git/git-checkout-worktree +++ b/.config/zsh/autoload/git/git-checkout-worktree @@ -7,7 +7,7 @@ # (e.g. stashing). Finally the temporary directory is deleted. local GIT_ROOT TEMP_DIR REPO_DIR -GIT_ROOT="$(basename "$(git rev-parse --show-toplevel)")" || return +GIT_ROOT="${$(git rev-parse --show-toplevel):t}" || return TEMP_DIR="$(mktemp -d)" REPO_DIR="$TEMP_DIR/$GIT_ROOT"