script/git-hooks: add check-trailing-whitespace
authorRalph Boehme <slow at samba.org>
Tue, 10 Apr 2018 11:19:09 +0000 (13:19 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 26 Apr 2018 01:54:38 +0000 (03:54 +0200)
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Martin Schwenke <martin at meltin.net>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr 26 03:54:39 CEST 2018 on sn-devel-144

script/git-hooks/check-trailing-whitespace [new file with mode: 0755]
script/git-hooks/pre-commit-script

diff --git a/script/git-hooks/check-trailing-whitespace b/script/git-hooks/check-trailing-whitespace
new file mode 100755 (executable)
index 0000000..5303f1f
--- /dev/null
@@ -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
index 22ebecec9701dd406f45fe3b2b5f0e919aeb791d..015a553fb457b8dbfb2c5741b9e7846bd58e7a71 100755 (executable)
@@ -14,4 +14,6 @@ if [ $? -ne 0 ] ; then
     exit 1
 fi
 
+${gitdir}/script/git-hooks/check-trailing-whitespace || exit $?
+
 exit 0