+## add hook shims to a repo
+## usage: do_hookify <repo-path> <relative-hook-path>
+function do_hookify() {
+ TGT="$1"
+ HOOK_DIR="$2"
+ if [ -n "$CIVICRM_GIT_HOOKS" ]; then
+ echo "[[Install recommended hooks ($TGT)]]"
+ for HOOK in commit-msg post-checkout post-merge pre-commit prepare-commit-msg post-commit pre-rebase post-rewrite ;do
+ cat << TMPL > "$TGT/.git/hooks/$HOOK"
+#!/bin/bash
+if [ -f "\$GIT_DIR/${HOOK_DIR}/${HOOK}" ]; then
+ source "\$GIT_DIR/${HOOK_DIR}/${HOOK}"
+fi
+TMPL
+ chmod +x "$TGT/.git/hooks/$HOOK"
+ done
+ else
+ echo "[[Skip hook installation ($TGT) -- use \"--hooks\" to enable]]"
+ fi
+}
+