xref: /spdk/.githooks/pre-commit (revision 22898a91b9b6f289933db19b0175821cfb7e7820)
1#!/bin/sh
2#
3# Verify what is about to be committed.
4# Called by "git commit" with no arguments.  The hook should
5# exit with non-zero status after issuing an appropriate message if
6# it wants to stop the commit.
7
8rc=0
9
10# Redirect output to stderr.
11exec 1>&2
12
13# If there are formatting errors, print the offending file names and fail.
14if [ -x "./scripts/check_format.sh" ]; then
15	echo "Running check_format.sh ..."
16	"./scripts/check_format.sh" > check_format.log 2>&1
17	rc=$?
18	if [ $rc -ne 0 ]; then
19		cat check_format.log
20		echo ""
21		echo "ERROR check_format.sh returned errors!"
22		echo "ERROR Fix the problem and use 'git add' to update your changes."
23		echo "ERROR See `pwd`/check_format.log for more information."
24		echo ""
25	fi
26fi
27
28exit $rc
29