all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: emacs-devel@gnu.org
Subject: Re: .git/hooks/commit-msg
Date: Wed, 10 Dec 2014 23:25:36 -0800	[thread overview]
Message-ID: <548946F0.4050105@cs.ucla.edu> (raw)
In-Reply-To: <877fxza4pa.fsf@lifelogs.com>

[-- Attachment #1: Type: text/plain, Size: 401 bytes --]

Ted Zlatanov wrote:
> mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

Yeowch.  Talk about software archaeology.  Please install 'gawk'; it may be 
slower than mawk, but it's much better about compatibility, supports UTF-8, 
etc., etc.

To help forestall future problems like this I installed the attached patch into 
the emacs-24 branch; it should get merged into the master branch eventually.

[-- Attachment #2: 0001-Port-commit-msg-to-mawk.patch --]
[-- Type: text/x-diff, Size: 3005 bytes --]

From 371835ef9d3a41cfb1cb85e8a8acce933028ce39 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 10 Dec 2014 23:17:04 -0800
Subject: [PATCH] Port commit-msg to mawk

Problem reported by Ted Zlatanov in:
http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg01093.html
* build-aux/git-hooks/commit-msg (space, non_space, non_print):
New vars.  Use them as approximations to POSIX bracket expressions,
on implementations like mawk that do not support POSIX regexps.
---
 ChangeLog                      |  7 +++++++
 build-aux/git-hooks/commit-msg | 26 ++++++++++++++++++++------
 2 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d4a4f28..39d3eae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2014-12-11  Paul Eggert  <eggert@cs.ucla.edu>
 
+	Port commit-msg to mawk
+	Problem reported by Ted Zlatanov in:
+	http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg01093.html
+	* build-aux/git-hooks/commit-msg (space, non_space, non_print):
+	New vars.  Use them as approximations to POSIX bracket expressions,
+	on implementations like mawk that do not support POSIX regexps.
+
 	Improve commit-msg messages and autosquash
 	Problem reported by Michal Nazarewicz in Bug#19337.
 	* build-aux/git-hooks/commit-msg: Add "commit message" to
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index d2a0c59..5eb994c 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -46,6 +46,20 @@ fi
 
 # Check the log entry.
 exec $awk '
+  BEGIN {
+    if (" " ~ /[[:space:]]/) {
+      space = "[[:space:]]"
+      non_space = "[^[:space:]]"
+      non_print = "[^[:print:]]"
+    } else {
+      # mawk 1.3.3 does not support POSIX bracket expressions.
+      # Approximate them as best we can.
+      space = "[ \f\n\r\t\v]"
+      non_space = "[^ \f\n\r\t\v]"
+      non_print = "[\1-\37\177]"
+    }
+  }
+
   /^#/ { next }
 
   !/^.*$/ {
@@ -53,7 +67,7 @@ exec $awk '
     status = 1
   }
 
-  nlines == 0 && !/[^[:space:]]/ { next }
+  nlines == 0 && $0 !~ non_space { next }
 
   { nlines++ }
 
@@ -62,18 +76,18 @@ exec $awk '
     if (! sub(/^fixup! /, ""))
       sub(/^squash! /, "")
 
-    if (/^[[:space:]]/) {
+    if ($0 ~ "^" space) {
       print "White space at start of commit message'\''s first line"
       status = 1
     }
   }
 
-  nlines == 2 && /[^[:space:]]/ {
+  nlines == 2 && $0 ~ non_space {
     print "Nonempty second line in commit message"
     status = 1
   }
 
-  72 < length && /[[:space:]]/ {
+  72 < length && $0 ~ space {
     print "Line longer than 72 characters in commit message"
     status = 1
   }
@@ -88,11 +102,11 @@ exec $awk '
     status = 1
   }
 
-  /[^[:print:]]/ {
+  $0 ~ non_print {
     if (gsub(/\t/, "")) {
       print "Tab in commit message; please use spaces instead"
     }
-    if (/[^[:print:]]/) {
+    if ($0 ~ non_print) {
       print "Unprintable character in commit message"
     }
     status = 1
-- 
1.9.3


  reply	other threads:[~2014-12-11  7:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-07 16:19 .git/hooks/commit-msg Jan D.
2014-12-07 16:36 ` .git/hooks/commit-msg Ted Zlatanov
2014-12-08  1:14 ` .git/hooks/commit-msg Paul Eggert
2014-12-08 11:53   ` .git/hooks/commit-msg Jan D.
2014-12-10 15:45   ` .git/hooks/commit-msg Ted Zlatanov
2014-12-11  7:25     ` Paul Eggert [this message]
2014-12-11 11:54       ` .git/hooks/commit-msg Ted Zlatanov
2014-12-12 18:03         ` .git/hooks/commit-msg Paul Eggert
2014-12-13  0:50           ` .git/hooks/commit-msg Ted Zlatanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=548946F0.4050105@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.