Commit 9ac03320 authored by Paul Eggert's avatar Paul Eggert
Browse files

Improve commit-msg messages and autosquash

Problem reported by Michal Nazarewicz in Bug#19337.
* build-aux/git-hooks/commit-msg: Add "commit message" to
diagnostics.  Distinguish better between tabs and other
unprintable chars in diagnostics.  Don't complain if a prefix
"fixup! " or "squash! " makes a summary line too long.
parent 0c2f254b
2014-12-11 Paul Eggert <eggert@cs.ucla.edu>
Improve commit-msg messages and autosquash
Problem reported by Michal Nazarewicz in Bug#19337.
* build-aux/git-hooks/commit-msg: Add "commit message" to
diagnostics. Distinguish better between tabs and other
unprintable chars in diagnostics. Don't complain if a prefix
"fixup! " or "squash! " makes a summary line too long.
2014-12-08 Paul Eggert <eggert@cs.ucla.edu> 2014-12-08 Paul Eggert <eggert@cs.ucla.edu>
Port commit-message checking to FreeBSD 9. Port commit-message checking to FreeBSD 9.
......
...@@ -49,7 +49,7 @@ exec $awk ' ...@@ -49,7 +49,7 @@ exec $awk '
/^#/ { next } /^#/ { next }
!/^.*$/ { !/^.*$/ {
print "Invalid character (not UTF-8)" print "Invalid character (not UTF-8) in commit message"
status = 1 status = 1
} }
...@@ -57,39 +57,50 @@ exec $awk ' ...@@ -57,39 +57,50 @@ exec $awk '
{ nlines++ } { nlines++ }
nlines == 1 && /^[[:space:]]/ { nlines == 1 {
print "White space at start of first line" # Ignore special markers used by "git rebase --autosquash".
status = 1 if (! sub(/^fixup! /, ""))
} sub(/^squash! /, "")
nlines == 2 && /[^[:space:]]/ { if (/^[[:space:]]/) {
print "Nonempty second line" print "White space at start of commit message'\''s first line"
status = 1 status = 1
} }
}
/[^[:print:]]/ { nlines == 2 && /[^[:space:]]/ {
print "Unprintable character; please use spaces instead of tabs" print "Nonempty second line in commit message"
status = 1 status = 1
} }
72 < length && /[[:space:]]/ { 72 < length && /[[:space:]]/ {
print "Line longer than 72 characters" print "Line longer than 72 characters in commit message"
status = 1 status = 1
} }
140 < length { 140 < length {
print "Word longer than 140 characters" print "Word longer than 140 characters in commit message"
status = 1 status = 1
} }
/^Signed-off-by: / { /^Signed-off-by: / {
print "'\''Signed-off-by:'\'' present" print "'\''Signed-off-by:'\'' in commit message"
status = 1
}
/[^[:print:]]/ {
if (gsub(/\t/, "")) {
print "Tab in commit message; please use spaces instead"
}
if (/[^[:print:]]/) {
print "Unprintable character in commit message"
}
status = 1 status = 1
} }
END { END {
if (nlines == 0) { if (nlines == 0) {
print "Empty change log entry" print "Empty commit message"
status = 1 status = 1
} }
exit status exit status
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment