Permalink
Browse files

add "tracked" git hooks which can be installed by running git/install…

…-hook-symlinks

it will also be installed by gerrit-clone in the future

Change-Id: Ib01ae6338e637dd58f4f987d0359f885abd959a1
  • Loading branch information...
1 parent 27a3561 commit 59c53151150f120c8bd5cd69ba1ee91417026a34 Vadim Spivak committed Aug 29, 2011
Showing with 47 additions and 0 deletions.
  1. +1 −0 .gitattributes
  2. +7 −0 git/hooks-wrapper
  3. +28 −0 git/install-hook-symlinks
  4. +11 −0 git/tracked_hooks/pre-commit
View
@@ -0,0 +1 @@
+* whitespace=trailing-space,tab-in-indent
View
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [ -x $0.local ]; then
+ $0.local "$@" || exit $?
+fi
+if [ -x tracked_hooks/$(basename $0) ]; then
+ tracked_hooks/$(basename $0) "$@" || exit $?
+fi
@@ -0,0 +1,28 @@
+#!/bin/bash
+HOOK_NAMES="
+applypatch-msg
+pre-applypatch
+post-applypatch
+pre-commit
+prepare-commit-msg
+commit-msg
+post-commit
+pre-rebase
+post-checkout
+post-merge
+pre-receive
+update
+post-receive
+post-update
+pre-auto-gc
+"
+
+HOOK_SRC=$(dirname $0)
+HOOK_DIR=$(git rev-parse --git-dir)/hooks || exit $?
+
+for hook in $HOOK_NAMES; do
+ if [ ! -h $HOOK_DIR/$hook -a -x $HOOK_DIR/$hook ]; then
+ mv $HOOK_DIR/$hook $HOOK_DIR/$hook.local
+ fi
+ ln -s -f ../../git/hooks-wrapper $HOOK_DIR/$hook
+done
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if git rev-parse --verify HEAD >/dev/null 2>&1
+then
+ against=HEAD
+else
+ # Initial commit: diff against an empty tree object
+ against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
+fi
+
+exec git diff-index --check --cached $against --

0 comments on commit 59c5315

Please sign in to comment.