]> code.delx.au - gnu-emacs/commitdiff
* build-aux/git-hooks/commit-msg: Allow tabs.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 28 Dec 2014 18:05:14 +0000 (10:05 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 28 Dec 2014 18:07:56 +0000 (10:07 -0800)
Treat them as if they were expanded to spaces, with tab stops
every 8 columns.

ChangeLog
build-aux/git-hooks/commit-msg

index b6d0fcbb92ddc27492b243522e26847e671b746d..1b161abf11b64a7d0ffeaa3040de20d0471cfd69 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-12-28  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * build-aux/git-hooks/commit-msg: Allow tabs.
+       Treat them as if they were expanded to spaces, with tab stops
+       every 8 columns.
+
 2014-12-17  Paul Eggert  <eggert@cs.ucla.edu>
 
        * .gitignore: Ignore /conftest*.
index 2e3e4f21cda8223c867cbabf21fd7abd50041eec..9b6179ee6135dbf179bf68183e80770f108d6ed1 100755 (executable)
@@ -87,6 +87,15 @@ exec $awk '
     status = 1
   }
 
+  {
+    # Expand tabs to spaces for length calculations etc.
+    while (match($0, /\t/)) {
+      before_tab = substr($0, 1, RSTART - 1)
+      after_tab = substr($0, RSTART + 1)
+      $0 = sprintf("%s%*s%s", before_tab, 8 - (RSTART - 1) % 8, "", after_tab)
+    }
+  }
+
   78 < length && $0 ~ space {
     print "Line longer than 78 characters in commit message"
     status = 1
@@ -103,12 +112,7 @@ exec $awk '
   }
 
   $0 ~ non_print {
-    if (gsub(/\t/, "")) {
-      print "Tab in commit message; please use spaces instead"
-    }
-    if ($0 ~ non_print) {
-      print "Unprintable character in commit message"
-    }
+    print "Unprintable character in commit message"
     status = 1
   }