aboutsummaryrefslogtreecommitdiffstats
path: root/build-aux/git-hooks/commit-msg
diff options
context:
space:
mode:
Diffstat (limited to 'build-aux/git-hooks/commit-msg')
-rwxr-xr-xbuild-aux/git-hooks/commit-msg39
1 files changed, 25 insertions, 14 deletions
diff --git a/build-aux/git-hooks/commit-msg b/build-aux/git-hooks/commit-msg
index f407881b0db..d2a0c59dace 100755
--- a/build-aux/git-hooks/commit-msg
+++ b/build-aux/git-hooks/commit-msg
@@ -49,7 +49,7 @@ exec $awk '
49 /^#/ { next } 49 /^#/ { next }
50 50
51 !/^.*$/ { 51 !/^.*$/ {
52 print "Invalid character (not UTF-8)" 52 print "Invalid character (not UTF-8) in commit message"
53 status = 1 53 status = 1
54 } 54 }
55 55
@@ -57,39 +57,50 @@ exec $awk '
57 57
58 { nlines++ } 58 { nlines++ }
59 59
60 nlines == 1 && /^[[:space:]]/ { 60 nlines == 1 {
61 print "White space at start of first line" 61 # Ignore special markers used by "git rebase --autosquash".
62 status = 1 62 if (! sub(/^fixup! /, ""))
63 } 63 sub(/^squash! /, "")
64 64
65 nlines == 2 && /[^[:space:]]/ { 65 if (/^[[:space:]]/) {
66 print "Nonempty second line" 66 print "White space at start of commit message'\''s first line"
67 status = 1 67 status = 1
68 }
68 } 69 }
69 70
70 /[^[:print:]]/ { 71 nlines == 2 && /[^[:space:]]/ {
71 print "Unprintable character; please use spaces instead of tabs" 72 print "Nonempty second line in commit message"
72 status = 1 73 status = 1
73 } 74 }
74 75
75 72 < length && /[[:space:]]/ { 76 72 < length && /[[:space:]]/ {
76 print "Line longer than 72 characters" 77 print "Line longer than 72 characters in commit message"
77 status = 1 78 status = 1
78 } 79 }
79 80
80 140 < length { 81 140 < length {
81 print "Word longer than 140 characters" 82 print "Word longer than 140 characters in commit message"
82 status = 1 83 status = 1
83 } 84 }
84 85
85 /^Signed-off-by: / { 86 /^Signed-off-by: / {
86 print "'\''Signed-off-by:'\'' present" 87 print "'\''Signed-off-by:'\'' in commit message"
88 status = 1
89 }
90
91 /[^[:print:]]/ {
92 if (gsub(/\t/, "")) {
93 print "Tab in commit message; please use spaces instead"
94 }
95 if (/[^[:print:]]/) {
96 print "Unprintable character in commit message"
97 }
87 status = 1 98 status = 1
88 } 99 }
89 100
90 END { 101 END {
91 if (nlines == 0) { 102 if (nlines == 0) {
92 print "Empty change log entry" 103 print "Empty commit message"
93 status = 1 104 status = 1
94 } 105 }
95 exit status 106 exit status