diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/pre-commit | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/pre-commit b/tools/pre-commit index aa34474c88..02a52b1a58 100755 --- a/tools/pre-commit +++ b/tools/pre-commit @@ -12,6 +12,13 @@ unset GREP_OPTIONS if [ -z $GIT_DIR ]; then GIT_DIR=".git"; fi +if [ -z $1 ]; then + COMMIT_ID="HEAD" +else + COMMIT_ID=$1 +fi + + # Check for newer versions of the pre-commit script if [ ${GIT_DIR}/hooks/pre-commit -ot ./tools/pre-commit ]; then echo "Pre-commit hook script is outdated, please update!" @@ -19,7 +26,7 @@ fi exit_status=0 -for FILE in `git diff-index --cached --name-status HEAD | grep -v "^D" | cut -f2 | grep "\.[ch]$"` ; do +for FILE in `git diff-index --cached --name-status ${COMMIT_ID} | grep -v "^D" | cut -f2 | grep "\.[ch]$"` ; do #Check if checkhf is good ./tools/checkhf.pl $FILE || exit_status=1 @@ -36,7 +43,7 @@ for FILE in `git diff-index --cached --name-status HEAD | grep -v "^D" | cut -f2 done # If there are whitespace errors, print the offending file names and fail. (from git pre-commit.sample) -git diff-index --check --cached HEAD || exit_status=1 +git diff-index --check --cached ${COMMIT_ID} || exit_status=1 exit $exit_status |