summaryrefslogtreecommitdiff
path: root/Utilities/Git
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-07-17 08:16:12 -0400
committerBrad King <brad.king@kitware.com>2012-07-17 08:16:12 -0400
commit873f21ad1bcbf900025b7cbddb50b94b37d198aa (patch)
tree6fc1ed8df20b00c102b7b8b071723927bcc237d7 /Utilities/Git
parentd17c58c8534ba68e527a79f33fad60c502ebdde1 (diff)
downloadcmake-873f21ad1bcbf900025b7cbddb50b94b37d198aa.tar.gz
pre-commit: Reject C++ code with lines too long
Check changes in Source/*.h and Source/*.cxx for lines longer than our style limit.
Diffstat (limited to 'Utilities/Git')
-rwxr-xr-xUtilities/Git/pre-commit20
1 files changed, 20 insertions, 0 deletions
diff --git a/Utilities/Git/pre-commit b/Utilities/Git/pre-commit
index 110e9ee350..d308a81b5d 100755
--- a/Utilities/Git/pre-commit
+++ b/Utilities/Git/pre-commit
@@ -19,6 +19,26 @@ die() {
exit 1
}
+#-------------------------------------------------------------------------------
+line_too_long=80
+bad=$(regex=".{$line_too_long}" &&
+git diff-index --cached HEAD --name-only --diff-filter=AM \
+ --pickaxe-regex -S"$regex" -- 'Source/*.h' 'Source/*.cxx' |
+while read file; do
+ lines_too_long=$(git diff-index -p --cached HEAD \
+ --pickaxe-regex -S"$regex" -- "$file")
+ if echo "$lines_too_long" | egrep -q '^\+'"$regex"; then
+ echo "$lines_too_long"
+ fi
+done)
+test -z "$bad" ||
+die 'The following changes add lines too long for our C++ style:
+
+'"$bad"'
+
+Use lines strictly less than '"$line_too_long"' characters in C++ code.'
+
+#-------------------------------------------------------------------------------
if test -z "$HOOKS_ALLOW_KWSYS"; then
# Disallow changes to KWSys
files=$(git diff-index --name-only --cached HEAD -- Source/kwsys) &&