From: Ralph Boehme Date: Tue, 10 Apr 2018 11:19:09 +0000 (+0200) Subject: script/git-hooks: add check-trailing-whitespace X-Git-Tag: ldb-1.4.0~528 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5757d259321f20fab349fd1a0d447473ba2c8fc6;p=thirdparty%2Fsamba.git script/git-hooks: add check-trailing-whitespace Signed-off-by: Ralph Boehme Reviewed-by: Martin Schwenke Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Apr 26 03:54:39 CEST 2018 on sn-devel-144 --- diff --git a/script/git-hooks/check-trailing-whitespace b/script/git-hooks/check-trailing-whitespace new file mode 100755 index 00000000000..5303f1fcefa --- /dev/null +++ b/script/git-hooks/check-trailing-whitespace @@ -0,0 +1,17 @@ +#!/bin/sh + +git diff-index --cached --check HEAD -- :/*.[ch] :/*.p[ylm] + +if [ $? != 0 ]; then + echo + echo "The commit failed because it seems to introduce trailing whitespace" + echo "into C, Perl, or Python code." + echo + echo "If you are sure you want to do this, repeat the commit with the " + echo "--no-verify, like this:" + echo + echo " git commit --no-verify" + exit 1 +fi + +exit 0 diff --git a/script/git-hooks/pre-commit-script b/script/git-hooks/pre-commit-script index 22ebecec970..015a553fb45 100755 --- a/script/git-hooks/pre-commit-script +++ b/script/git-hooks/pre-commit-script @@ -14,4 +14,6 @@ if [ $? -ne 0 ] ; then exit 1 fi +${gitdir}/script/git-hooks/check-trailing-whitespace || exit $? + exit 0