Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add git hook to check trailing whitespace

Change-Id: I51a420bec9f8aff71ed8323c0d90996d516f3401
  • Loading branch information...
commit 8fd6caff46dc4c9b919ade15491d5324bdf1ab37 1 parent 5b4473d
Jennifer Hickey authored
View
9 git/hooks-wrapper
@@ -0,0 +1,9 @@
+#!/bin/bash
+if [ -x $0.local ]; then
+ $0.local "$@" || exit $?
+fi
+
+REPO_DIR=$(dirname $GIT_DIR)
+if [ -x $REPO_DIR/git/tracked_hooks/$(basename $0) ]; then
+ $REPO_DIR/git/tracked_hooks/$(basename $0) "$@" || exit $?
+fi
View
28 git/install-hook-symlinks
@@ -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
View
11 git/tracked_hooks/pre-commit
@@ -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 --
Please sign in to comment.
Something went wrong with that request. Please try again.