From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: .git/hooks/commit-msg Date: Wed, 10 Dec 2014 23:25:36 -0800 Organization: UCLA Computer Science Department Message-ID: <548946F0.4050105@cs.ucla.edu> References: <57F3BCF0-60FD-416F-8F68-192A2A941821@swipnet.se> <5484FB75.4080501@cs.ucla.edu> <877fxza4pa.fsf@lifelogs.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010104010104090500010300" X-Trace: ger.gmane.org 1418282770 2225 80.91.229.3 (11 Dec 2014 07:26:10 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Dec 2014 07:26:10 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Dec 11 08:26:04 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xyy8S-0002BD-M3 for ged-emacs-devel@m.gmane.org; Thu, 11 Dec 2014 08:26:04 +0100 Original-Received: from localhost ([::1]:49605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyy8S-0005Aw-8W for ged-emacs-devel@m.gmane.org; Thu, 11 Dec 2014 02:26:04 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44176) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyy8J-0005Ak-P1 for emacs-devel@gnu.org; Thu, 11 Dec 2014 02:26:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xyy8D-0000g8-7n for emacs-devel@gnu.org; Thu, 11 Dec 2014 02:25:55 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:59159) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xyy8C-0000es-WF for emacs-devel@gnu.org; Thu, 11 Dec 2014 02:25:49 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 0DEA6A600CC for ; Wed, 10 Dec 2014 23:25:41 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XYaIubPPLYbx for ; Wed, 10 Dec 2014 23:25:36 -0800 (PST) Original-Received: from [192.168.1.9] (pool-71-177-17-123.lsanca.dsl-w.verizon.net [71.177.17.123]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id BDEE5A60013 for ; Wed, 10 Dec 2014 23:25:36 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <877fxza4pa.fsf@lifelogs.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 131.179.128.62 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:179723 Archived-At: This is a multi-part message in MIME format. --------------010104010104090500010300 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------010104010104090500010300 Content-Type: text/x-diff; name="0001-Port-commit-msg-to-mawk.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Port-commit-msg-to-mawk.patch" >From 371835ef9d3a41cfb1cb85e8a8acce933028ce39 Mon Sep 17 00:00:00 2001 From: Paul Eggert 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 + 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 --------------010104010104090500010300--