[ -d "@cmddir@" ] ||
die "No command directory: '@cmddir@'"
+# Make sure we are in the worktree, not under .git
+is_inside_repo=1
+is_inside_git_dir=$(git rev-parse --is-inside-git-dir 2>/dev/null) ||
+ is_inside_repo=0
+
+case "$is_inside_repo/$is_inside_git_dir" in
+0*) die "Cannot run outside of a Git repository.";;
+1/true) die "Cannot run from inside \`.git\` hierarchy, please switch to work-tree.";;
+esac
+
## Initial setup
set -e