#!/bin/sh

# copy this file to .git/hooks (i.e., overwrite the file .git/hooks/pre-commit)
# to perform source checks before commits

# different versions of git use different letters for deleted/removed files
FILES=`git diff --cached --name-status HEAD | \
  awk '$1 != "R" && $1 != "D" { print $2 }' | \
  grep -v -e 'src/external'                 | \
  grep -e '.*\.c$' -e '.*\.h$'`

if [ ${#FILES} -gt 0 ]
then
  $PWD/scripts/src_check $FILES
else
  exit 0
fi
