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.
This commit is contained in:
2022-03-31 15:33:53 +02:00
parent eb323992dc
commit 02a0e17bcb

View File

@@ -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"