#!/bin/bash

if REV=$(git rev-parse -q --verify HEAD); then
	against=HEAD
else
	# Initial commit: diff against an empty tree object
	against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi

FILES=$(git diff-index --name-only --cached --diff-filter=ACMR $against -- | grep .php )

if [ "$FILES" == "" ]; then
	echo "No files to check with PHPCS."
	exit 0
fi

set -ex

{{PHPCS_BIN}} -s $FILES
