exit 1
}
+# Make sure we are in the worktree, not under .git; die otherwise
+ensure_git_repo_or_die()
+{
+ local is_inside_repo is_inside_git_dir
+ 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
+}
+
# setup_hook NAME
setup_hook()
{
[ -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
+ensure_git_repo_or_die
## Initial setup