diff options
| author | Paul Eggert | 2014-12-10 23:17:04 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-12-10 23:17:42 -0800 |
| commit | 75b4857ef040863b4d53ea2a27993fdd8370f7af (patch) | |
| tree | b0143338cbc236782d789b248fd15fcb4d6ee319 | |
| parent | 9ac033203005ba53c4f1e65fcb44ae95edf1b402 (diff) | |
| download | emacs-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.
| -rw-r--r-- | ChangeLog | 7 | ||||
| -rwxr-xr-x | build-aux/git-hooks/commit-msg | 26 |
2 files changed, 27 insertions, 6 deletions
| @@ -1,5 +1,12 @@ | |||
| 1 | 2014-12-11 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2014-12-11 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | Port commit-msg to mawk | ||
| 4 | Problem reported by Ted Zlatanov in: | ||
| 5 | http://lists.gnu.org/archive/html/emacs-devel/2014-12/msg01093.html | ||
| 6 | * build-aux/git-hooks/commit-msg (space, non_space, non_print): | ||
| 7 | New vars. Use them as approximations to POSIX bracket expressions, | ||
| 8 | on implementations like mawk that do not support POSIX regexps. | ||
| 9 | |||
| 3 | Improve commit-msg messages and autosquash | 10 | Improve commit-msg messages and autosquash |
| 4 | Problem reported by Michal Nazarewicz in Bug#19337. | 11 | Problem reported by Michal Nazarewicz in Bug#19337. |
| 5 | * build-aux/git-hooks/commit-msg: Add "commit message" to | 12 | * 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 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. |
| 48 | exec $awk ' | 48 | exec $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 |