blob: fd7ff128f32fdb2bf4eebf3d82487efebe767950 [file] [log] [blame]
Hans-Christoph Steiner0761ec32019-01-09 13:00:45 +01001#!/bin/sh
2#
3# Install all the client hooks
4
5BASE_DIR="$(cd $(dirname $0); pwd -P)"
6HOOK_NAMES="applypatch-msg pre-applypatch post-applypatch pre-commit prepare-commit-msg commit-msg post-commit pre-rebase post-checkout post-merge pre-push post-push pre-receive update post-receive post-update pre-auto-gc"
7HOOK_DIR="$(git rev-parse --show-toplevel)/.git/hooks"
8
9for hook in $HOOK_NAMES; do
10
11 shipped_hook="$BASE_DIR/$hook"
12 installed_hook="$HOOK_DIR/$hook"
13
14 # If we don't distribute it, continue
15 if [ ! -f "$shipped_hook" ]; then
16 continue
17 fi
18
19 if [ -h "$installed_hook" ]; then
20 echo "$installed_hook is a symlink - replacing."
21 elif [ -e "$installed_hook" ]; then
22 echo "$installed_hook hook already exists."
23 continue
24 fi
25
26 # Create the symlink
27 echo "ln -s -f \"$shipped_hook\" \"$installed_hook\""
28 ln -s -f "$shipped_hook" "$installed_hook"
29
30done