unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* .git/hooks/commit-msg
@ 2014-12-07 16:19 Jan D.
  2014-12-07 16:36 ` .git/hooks/commit-msg Ted Zlatanov
  2014-12-08  1:14 ` .git/hooks/commit-msg Paul Eggert
  0 siblings, 2 replies; 9+ messages in thread
From: Jan D. @ 2014-12-07 16:19 UTC (permalink / raw)
  To: emacs-devel@gnu.org Development

Hello.

Is .git/hooks/commit-msg something we enabled?
It keeps complaining about control caracter, even if there are none.
I had to disable that check to be able to commit.
Does it assume GNU awk?

	Jan D.




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  2014-12-07 16:19 .git/hooks/commit-msg Jan D.
@ 2014-12-07 16:36 ` Ted Zlatanov
  2014-12-08  1:14 ` .git/hooks/commit-msg Paul Eggert
  1 sibling, 0 replies; 9+ messages in thread
From: Ted Zlatanov @ 2014-12-07 16:36 UTC (permalink / raw)
  To: emacs-devel

On Sun, 7 Dec 2014 17:19:38 +0100 "Jan D." <jan.h.d@swipnet.se> wrote: 

JD> Is .git/hooks/commit-msg something we enabled?

It gets installed when you build Emacs.

JD> It keeps complaining about control caracter, even if there are none.
JD> I had to disable that check to be able to commit.
JD> Does it assume GNU awk?

Not sure, sorry.  I also had a problem with the dynamic-modules branch
when I squashed everything into a single commit, but was unable to debug
it for lack of time.

Ted




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  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 ` Paul Eggert
  2014-12-08 11:53   ` .git/hooks/commit-msg Jan D.
  2014-12-10 15:45   ` .git/hooks/commit-msg Ted Zlatanov
  1 sibling, 2 replies; 9+ messages in thread
From: Paul Eggert @ 2014-12-08  1:14 UTC (permalink / raw)
  To: Jan D., emacs-devel@gnu.org Development

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

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 <http://bugs.freebsd.org/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.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Port-commit-message-checking-to-FreeBSD-9.patch --]
[-- Type: text/x-diff; name="0001-Port-commit-message-checking-to-FreeBSD-9.patch", Size: 3287 bytes --]

From 0f9fbb922cb029b0c36805d260a5db28e25d3dd1 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
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=UTF-8
Content-Transfer-Encoding: 8bit

This fixes a bug reported by Jan Djärv 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  <eggert@cs.ucla.edu>
+
+	Port commit-message checking to FreeBSD 9.
+	This fixes a bug reported by Jan Djärv 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  <monnier@iro.umontreal.ca>
 
 	* .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 @@
 
 # Written by Paul Eggert.
 
+# Prefer gawk if available, as it handles NUL bytes properly.
+if type gawk >/dev/null 2>&1; then
+  awk=gawk
+else
+  awk=awk
+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='\302\242'
 at_sign=`
   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" != @; then
   at_sign=`
     printf "${cent_sign_utf8_octal}@" |
-    LC_ALL=en_US.utf8 awk '{print substr($0, 2)}' 2>/dev/null
+    LC_ALL=en_US.UTF-8 $awk '{print substr($0, 2)}' 2>/dev/null
   `
   if test "$at_sign" = @; then
-    LC_ALL=en_US.utf8; export LC_ALL
+    LC_ALL=en_US.UTF-8; export LC_ALL
   fi
 fi
 
 # Check the log entry.
-exec awk '
+exec $awk '
   /^#/ { next }
 
   !/^.*$/ {
@@ -60,8 +67,8 @@ exec awk '
     status = 1
   }
 
-  /[[:cntrl:]]/ {
-    print "Text contains control character; please use spaces instead of tabs"
+  /[^[:print:]]/ {
+    print "Unprintable character; please use spaces instead of tabs"
     status = 1
   }
 
@@ -76,7 +83,7 @@ exec awk '
   }
 
   /^Signed-off-by: / {
-    print "'Signed-off-by:' present"
+    print "'\''Signed-off-by:'\'' present"
     status = 1
   }
 
-- 
1.9.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  2014-12-08  1:14 ` .git/hooks/commit-msg Paul Eggert
@ 2014-12-08 11:53   ` Jan D.
  2014-12-10 15:45   ` .git/hooks/commit-msg Ted Zlatanov
  1 sibling, 0 replies; 9+ messages in thread
From: Jan D. @ 2014-12-08 11:53 UTC (permalink / raw)
  To: Paul Eggert, emacs-devel@gnu.org Development

Paul Eggert skrev den 2014-12-08 02:14:
> 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 <http://bugs.freebsd.org/195792>.

Ah, so thats it.  I can confirm OSX has this bug.

>
> 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.

Thanks.

	Jan D.





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  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   ` Ted Zlatanov
  2014-12-11  7:25     ` .git/hooks/commit-msg Paul Eggert
  1 sibling, 1 reply; 9+ messages in thread
From: Ted Zlatanov @ 2014-12-10 15:45 UTC (permalink / raw)
  To: emacs-devel

On Sun, 07 Dec 2014 17:14:29 -0800 Paul Eggert <eggert@cs.ucla.edu> wrote: 

PE> Jan D. wrote:
>> It keeps complaining about control caracter, even if there are none....
>> Does it assume GNU awk?

PE> No, it assumes only POSIX awk.  However, it turns out that FreeBSD awk
PE> is buggy here; see FreeBSD bug#195792
PE> <http://bugs.freebsd.org/195792>.

PE> I worked around the FreeBSD bug by installing the attached patch to
PE> the emacs-24 branch; this should be merged into the Emacs master in
PE> due course.  After applying the patch, you can run './autogen.sh' to
PE> propagate the fix into your .git/hooks/commit-msg.

On my Ubuntu system:

mawk 1.3.3 Nov 1996, Copyright (C) Michael D. Brennan

this line:

    nlines == 0 && !/[^[:space:]]/ { next }

skips all lines, so I end up with "Empty change log entry" and an abort.
For now I've removed it because I don't know awk well, so I can't fix it
properly myself.

I can rewrite that script in Perl if it's better.  Whatever works.

Ted




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  2014-12-10 15:45   ` .git/hooks/commit-msg Ted Zlatanov
@ 2014-12-11  7:25     ` Paul Eggert
  2014-12-11 11:54       ` .git/hooks/commit-msg Ted Zlatanov
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Eggert @ 2014-12-11  7:25 UTC (permalink / raw)
  To: emacs-devel

[-- 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


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  2014-12-11  7:25     ` .git/hooks/commit-msg Paul Eggert
@ 2014-12-11 11:54       ` Ted Zlatanov
  2014-12-12 18:03         ` .git/hooks/commit-msg Paul Eggert
  0 siblings, 1 reply; 9+ messages in thread
From: Ted Zlatanov @ 2014-12-11 11:54 UTC (permalink / raw)
  To: emacs-devel

On Wed, 10 Dec 2014 23:25:36 -0800 Paul Eggert <eggert@cs.ucla.edu> wrote: 

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

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

This is the default on Ubuntu 14.04.1 LTS.  You have to deal with these
issues if you want to write a generic script.

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

Is Perl so bad?  People are much less likely to have a 1996 version of it.

Ted




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  2014-12-11 11:54       ` .git/hooks/commit-msg Ted Zlatanov
@ 2014-12-12 18:03         ` Paul Eggert
  2014-12-13  0:50           ` .git/hooks/commit-msg Ted Zlatanov
  0 siblings, 1 reply; 9+ messages in thread
From: Paul Eggert @ 2014-12-12 18:03 UTC (permalink / raw)
  To: emacs-devel

Ted Zlatanov wrote:
> Is Perl so bad?

It's not bad, but awk is standardized and Emacs already uses awk so it's one 
less dependency if we just keep using awk for little things like this.  Besides, 
Perl versioning also has its pitfalls....



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: .git/hooks/commit-msg
  2014-12-12 18:03         ` .git/hooks/commit-msg Paul Eggert
@ 2014-12-13  0:50           ` Ted Zlatanov
  0 siblings, 0 replies; 9+ messages in thread
From: Ted Zlatanov @ 2014-12-13  0:50 UTC (permalink / raw)
  To: emacs-devel

On Fri, 12 Dec 2014 10:03:27 -0800 Paul Eggert <eggert@cs.ucla.edu> wrote: 

PE> Ted Zlatanov wrote:
>> Is Perl so bad?

PE> It's not bad, but awk is standardized and Emacs already uses awk so
PE> it's one less dependency if we just keep using awk for little things
PE> like this.  Besides, Perl versioning also has its pitfalls....

Got it, thanks.  This should probably be a comment at the top of those
commit hooks for complainers like me :)

Ted




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-13  0:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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     ` .git/hooks/commit-msg Paul Eggert
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).