aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/git-hooks/commit-msg
diff options
context:
space:
mode:
authorPaul Eggert2014-12-10 23:17:04 -0800
committerPaul Eggert2014-12-10 23:17:42 -0800
commit75b4857ef040863b4d53ea2a27993fdd8370f7af (patch)
treeb0143338cbc236782d789b248fd15fcb4d6ee319 /build-aux/git-hooks/commit-msg
parent9ac033203005ba53c4f1e65fcb44ae95edf1b402 (diff)
downloademacs-75b4857ef040863b4d53ea2a27993fdd8370f7af.tar.gz
emacs-75b4857ef040863b4d53ea2a27993fdd8370f7af.zip
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.
Diffstat (limited to 'build-aux/git-hooks/commit-msg')
-rwxr-xr-xbuild-aux/git-hooks/commit-msg26
1 files changed, 20 insertions, 6 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index d2a0c59dace..5eb994c6fe0 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -46,6 +46,20 @@ fi
46 46
47# Check the log entry. 47# Check the log entry.
48exec $awk ' 48exec $awk '
49 BEGIN {
50 if (" " ~ /[[:space:]]/) {
51 space = "[[:space:]]"
52 non_space = "[^[:space:]]"
53 non_print = "[^[:print:]]"
54 } else {
55 # mawk 1.3.3 does not support POSIX bracket expressions.
56 # Approximate them as best we can.
57 space = "[ \f\n\r\t\v]"
58 non_space = "[^ \f\n\r\t\v]"
59 non_print = "[\1-\37\177]"
60 }
61 }
62
49 /^#/ { next } 63 /^#/ { next }
50 64
51 !/^.*$/ { 65 !/^.*$/ {
@@ -53,7 +67,7 @@ exec $awk '
53 status = 1 67 status = 1
54 } 68 }
55 69
56 nlines == 0 && !/[^[:space:]]/ { next } 70 nlines == 0 && $0 !~ non_space { next }
57 71
58 { nlines++ } 72 { nlines++ }
59 73
@@ -62,18 +76,18 @@ exec $awk '
62 if (! sub(/^fixup! /, "")) 76 if (! sub(/^fixup! /, ""))
63 sub(/^squash! /, "") 77 sub(/^squash! /, "")
64 78
65 if (/^[[:space:]]/) { 79 if ($0 ~ "^" space) {
66 print "White space at start of commit message'\''s first line" 80 print "White space at start of commit message'\''s first line"
67 status = 1 81 status = 1
68 } 82 }
69 } 83 }
70 84
71 nlines == 2 && /[^[:space:]]/ { 85 nlines == 2 && $0 ~ non_space {
72 print "Nonempty second line in commit message" 86 print "Nonempty second line in commit message"
73 status = 1 87 status = 1
74 } 88 }
75 89
76 72 < length && /[[:space:]]/ { 90 72 < length && $0 ~ space {
77 print "Line longer than 72 characters in commit message" 91 print "Line longer than 72 characters in commit message"
78 status = 1 92 status = 1
79 } 93 }
@@ -88,11 +102,11 @@ exec $awk '
88 status = 1 102 status = 1
89 } 103 }
90 104
91 /[^[:print:]]/ { 105 $0 ~ non_print {
92 if (gsub(/\t/, "")) { 106 if (gsub(/\t/, "")) {
93 print "Tab in commit message; please use spaces instead" 107 print "Tab in commit message; please use spaces instead"
94 } 108 }
95 if (/[^[:print:]]/) { 109 if ($0 ~ non_print) {
96 print "Unprintable character in commit message" 110 print "Unprintable character in commit message"
97 } 111 }
98 status = 1 112 status = 1