#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments.  The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# To enable this hook, rename this file to "pre-commit".

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

# Redirect output to stderr.
exec 1>&2
files=`git diff-index --name-only $against`
if test -n "$files"
then
  if python `git rev-parse --show-toplevel`/.git/hooks/check-standards.py `git diff-index --name-only $against`
  then
    echo "Format checks OK."
  else
    exit 1
  fi
fi

untracked=`git status -u --porcelain | grep '^??'`
if test -n "$untracked"
then
  echo "$(tput setaf 1)ERROR: There are untracked files in your repository.$(tput sgr0)"
  echo "If you want to keep them around you can add them to your .git/info/exclude file: " `echo $untracked | cut -f2 -d\ `
  echo "You can use --no-verify to skip checks if you are sure that is what you want."
  exit 1
fi
