diff options
Diffstat (limited to 'build-aux/git-hooks/commit-msg')
| -rwxr-xr-x | build-aux/git-hooks/commit-msg | 26 |
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. |
| 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 |