summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorRalph Boehme <slow at samba.org>2018-04-10 13:19:09 +0200
committerJeremy Allison <jra@samba.org>2018-04-26 03:54:38 +0200
commit5757d259321f20fab349fd1a0d447473ba2c8fc6 (patch)
treeccd5a0ee840d7bf7a93208024d808498212c9e7a /script
parent8649e216650de85cd73eda64caa2e338d59582d5 (diff)
downloadsamba-5757d259321f20fab349fd1a0d447473ba2c8fc6.tar.gz
script/git-hooks: add check-trailing-whitespace
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
Diffstat (limited to 'script')
-rwxr-xr-xscript/git-hooks/check-trailing-whitespace17
-rwxr-xr-xscript/git-hooks/pre-commit-script2
2 files changed, 19 insertions, 0 deletions
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