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