aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/git-hooks/commit-msg
diff options
context:
space:
mode:
authorPaul Eggert2014-12-07 16:17:20 -0800
committerPaul Eggert2014-12-07 16:18:38 -0800
commit0f9fbb922cb029b0c36805d260a5db28e25d3dd1 (patch)
tree97d33f04ece6777c4e4ed2b1893735d93a63da7c /build-aux/git-hooks/commit-msg
parent3db1adacc654f33ee8d5c515214c9d5325ee7fc1 (diff)
downloademacs-0f9fbb922cb029b0c36805d260a5db28e25d3dd1.tar.gz
emacs-0f9fbb922cb029b0c36805d260a5db28e25d3dd1.zip
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.
Diffstat (limited to 'build-aux/git-hooks/commit-msg')
-rwxr-xr-xbuild-aux/git-hooks/commit-msg21
1 files changed, 14 insertions, 7 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index 6a09eddf88b..f407881b0db 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -20,25 +20,32 @@
20 20
21# Written by Paul Eggert. 21# Written by Paul Eggert.
22 22
23# Prefer gawk if available, as it handles NUL bytes properly.
24if type gawk >/dev/null 2>&1; then
25 awk=gawk
26else
27 awk=awk
28fi
29
23# Use a UTF-8 locale if available, so that the UTF-8 check works. 30# Use a UTF-8 locale if available, so that the UTF-8 check works.
24# Use U+00A2 CENT SIGN to test whether the locale works. 31# Use U+00A2 CENT SIGN to test whether the locale works.
25cent_sign_utf8_octal='\302\242' 32cent_sign_utf8_octal='\302\242'
26at_sign=` 33at_sign=`
27 printf "${cent_sign_utf8_octal}@" | 34 printf "${cent_sign_utf8_octal}@" |
28 awk '{print substr($0, 2)}' 2>/dev/null 35 $awk '{print substr($0, 2)}' 2>/dev/null
29` 36`
30if test "$at_sign" != @; then 37if test "$at_sign" != @; then
31 at_sign=` 38 at_sign=`
32 printf "${cent_sign_utf8_octal}@" | 39 printf "${cent_sign_utf8_octal}@" |
33 LC_ALL=en_US.utf8 awk '{print substr($0, 2)}' 2>/dev/null 40 LC_ALL=en_US.UTF-8 $awk '{print substr($0, 2)}' 2>/dev/null
34 ` 41 `
35 if test "$at_sign" = @; then 42 if test "$at_sign" = @; then
36 LC_ALL=en_US.utf8; export LC_ALL 43 LC_ALL=en_US.UTF-8; export LC_ALL
37 fi 44 fi
38fi 45fi
39 46
40# Check the log entry. 47# Check the log entry.
41exec awk ' 48exec $awk '
42 /^#/ { next } 49 /^#/ { next }
43 50
44 !/^.*$/ { 51 !/^.*$/ {
@@ -60,8 +67,8 @@ exec awk '
60 status = 1 67 status = 1
61 } 68 }
62 69
63 /[[:cntrl:]]/ { 70 /[^[:print:]]/ {
64 print "Text contains control character; please use spaces instead of tabs" 71 print "Unprintable character; please use spaces instead of tabs"
65 status = 1 72 status = 1
66 } 73 }
67 74
@@ -76,7 +83,7 @@ exec awk '
76 } 83 }
77 84
78 /^Signed-off-by: / { 85 /^Signed-off-by: / {
79 print "'Signed-off-by:' present" 86 print "'\''Signed-off-by:'\'' present"
80 status = 1 87 status = 1
81 } 88 }
82 89