From f2793ffd51d1e518ca631b37efb039704f540993 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Tue, 27 Jul 2010 17:01:41 +0200
Subject: [PATCH] ENH: allow #directive lines to exceed the 80-col line length
 limit

---
 bin/tools/pre-commit-hook | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook
index be4bb69b242..7d41b2e11c8 100755
--- a/bin/tools/pre-commit-hook
+++ b/bin/tools/pre-commit-hook
@@ -200,6 +200,34 @@ checkLineLengthNonComments()
     dieOnBadFiles "Limit code to 80 columns before pushing"
 }
 
+#
+# limit line length to 80-columns, except #directive lines
+#
+checkLineLengthNonDirective()
+{
+    badFiles=$(
+    for f in $fileList
+    do
+        # limit to *.[CH] files
+        case "$f" in
+        (*.[CH])
+            # parse line numbers from this (strip comment lines):
+            #        path/fileName:<lineNr>:   contents
+            lines=$(git grep --cached -n -e ".\{81,\}" -- "$f" |
+                sed -n \
+                    -e '\@^[^:]*:[^:]*: *#.*@b' \
+                    -e 's@^[^:]*:\([0-9]*\):.*@\1@p' |
+                tr '\n' ' '
+            )
+            [ -n "$lines" ] && echo "$Indent$f -- lines: $lines"
+        ;;
+        esac
+    done
+    )
+
+    dieOnBadFiles "Limit code to 80 columns before pushing"
+}
+
 
 
 # do all checks
@@ -215,7 +243,7 @@ checkIllegalCode
 checkCopyright
 
 # ensure code conforms to 80 columns max
-checkLineLength
+checkLineLengthNonDirective
 
 
 exit 0
-- 
GitLab