From: Paul Eggert <eggert@cs.ucla.edu>
To: "Jan D." <jan.h.d@swipnet.se>,
"emacs-devel@gnu.org Development" <emacs-devel@gnu.org>
Subject: Re: .git/hooks/commit-msg
Date: Sun, 07 Dec 2014 17:14:29 -0800 [thread overview]
Message-ID: <5484FB75.4080501@cs.ucla.edu> (raw)
In-Reply-To: <57F3BCF0-60FD-416F-8F68-192A2A941821@swipnet.se>
[-- 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
next prev parent reply other threads:[~2014-12-08 1:14 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 ` Paul Eggert [this message]
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
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=5484FB75.4080501@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=emacs-devel@gnu.org \
--cc=jan.h.d@swipnet.se \
/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.