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: Sun, 07 Dec 2014 17:14:29 -0800 Organization: UCLA Computer Science Department Message-ID: <5484FB75.4080501@cs.ucla.edu> References: <57F3BCF0-60FD-416F-8F68-192A2A941821@swipnet.se> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------020200070808020805000609" X-Trace: ger.gmane.org 1418001316 15095 80.91.229.3 (8 Dec 2014 01:15:16 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Dec 2014 01:15:16 +0000 (UTC) To: "Jan D." , "emacs-devel@gnu.org Development" Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Dec 08 02:15:10 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 1Xxmur-0004Cp-0d for ged-emacs-devel@m.gmane.org; Mon, 08 Dec 2014 02:15:09 +0100 Original-Received: from localhost ([::1]:59728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xxmup-0007DB-Vh for ged-emacs-devel@m.gmane.org; Sun, 07 Dec 2014 20:15:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45639) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxmuU-0007D6-EN for emacs-devel@gnu.org; Sun, 07 Dec 2014 20:14:51 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XxmuP-0000l3-LJ for emacs-devel@gnu.org; Sun, 07 Dec 2014 20:14:46 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:46152) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XxmuP-0000hJ-CT for emacs-devel@gnu.org; Sun, 07 Dec 2014 20:14:41 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 83148A60034; Sun, 7 Dec 2014 17:14:33 -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 8rg+4C+f6piG; Sun, 7 Dec 2014 17:14:29 -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 7546FA60007; Sun, 7 Dec 2014 17:14:29 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 In-Reply-To: <57F3BCF0-60FD-416F-8F68-192A2A941821@swipnet.se> 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:179342 Archived-At: This is a multi-part message in MIME format. --------------020200070808020805000609 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Jan D. wrote: > It keeps complaining about control caracter, even if there are none.... > Does it assume GNU awk? No, it assumes only POSIX awk. However, it turns out that FreeBSD awk is buggy here; see FreeBSD bug#195792 . I worked around the FreeBSD bug by installing the attached patch to the emacs-24 branch; this should be merged into the Emacs master in due course. After applying the patch, you can run './autogen.sh' to propagate the fix into your .git/hooks/commit-msg. --------------020200070808020805000609 Content-Type: text/x-diff; name="0001-Port-commit-message-checking-to-FreeBSD-9.patch" Content-Disposition: attachment; filename="0001-Port-commit-message-checking-to-FreeBSD-9.patch" Content-Transfer-Encoding: quoted-printable >From 0f9fbb922cb029b0c36805d260a5db28e25d3dd1 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 7 Dec 2014 16:17:20 -0800 Subject: [PATCH] Port commit-message checking to FreeBSD 9. MIME-Version: 1.0 Content-Type: text/plain; charset=3DUTF-8 Content-Transfer-Encoding: 8bit This fixes a bug reported by Jan Dj=C3=A4rv in: http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg00704.html along with some other issues I noticed while testing with FreeBSD. * build-aux/git-hooks/commit-msg: Prefer gawk if available. Prefer en_US.UTF-8 to en_US.utf8, as it's more portable. Work around bug in FreeBSD 9 awk, where /[[:cntrl:]]/ matches ordinary text characters. Be less tricky about quoting "'" in a shell script. --- ChangeLog | 12 ++++++++++++ build-aux/git-hooks/commit-msg | 21 ++++++++++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index d7fcd25..3686a68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2014-12-08 Paul Eggert + + Port commit-message checking to FreeBSD 9. + This fixes a bug reported by Jan Dj=C3=A4rv in: + http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg00704.html + along with some other issues I noticed while testing with FreeBSD. + * build-aux/git-hooks/commit-msg: Prefer gawk if available. + Prefer en_US.UTF-8 to en_US.utf8, as it's more portable. + Work around bug in FreeBSD 9 awk, where /[[:cntrl:]]/ matches + ordinary text characters. + Be less tricky about quoting "'" in a shell script. + 2014-12-05 Stefan Monnier =20 * .gitignore: Ignore autosave files. diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-= msg index 6a09edd..f407881 100755 --- a/build-aux/git-hooks/commit-msg +++ b/build-aux/git-hooks/commit-msg @@ -20,25 +20,32 @@ =20 # Written by Paul Eggert. =20 +# Prefer gawk if available, as it handles NUL bytes properly. +if type gawk >/dev/null 2>&1; then + awk=3Dgawk +else + awk=3Dawk +fi + # Use a UTF-8 locale if available, so that the UTF-8 check works. # Use U+00A2 CENT SIGN to test whether the locale works. cent_sign_utf8_octal=3D'\302\242' at_sign=3D` printf "${cent_sign_utf8_octal}@" | - awk '{print substr($0, 2)}' 2>/dev/null + $awk '{print substr($0, 2)}' 2>/dev/null ` if test "$at_sign" !=3D @; then at_sign=3D` printf "${cent_sign_utf8_octal}@" | - LC_ALL=3Den_US.utf8 awk '{print substr($0, 2)}' 2>/dev/null + LC_ALL=3Den_US.UTF-8 $awk '{print substr($0, 2)}' 2>/dev/null ` if test "$at_sign" =3D @; then - LC_ALL=3Den_US.utf8; export LC_ALL + LC_ALL=3Den_US.UTF-8; export LC_ALL fi fi =20 # Check the log entry. -exec awk ' +exec $awk ' /^#/ { next } =20 !/^.*$/ { @@ -60,8 +67,8 @@ exec awk ' status =3D 1 } =20 - /[[:cntrl:]]/ { - print "Text contains control character; please use spaces instead of= tabs" + /[^[:print:]]/ { + print "Unprintable character; please use spaces instead of tabs" status =3D 1 } =20 @@ -76,7 +83,7 @@ exec awk ' } =20 /^Signed-off-by: / { - print "'Signed-off-by:' present" + print "'\''Signed-off-by:'\'' present" status =3D 1 } =20 --=20 1.9.3 --------------020200070808020805000609--