diff options
| author | Paul Eggert | 2014-12-10 20:44:35 -0800 |
|---|---|---|
| committer | Paul Eggert | 2014-12-10 20:45:02 -0800 |
| commit | 9ac033203005ba53c4f1e65fcb44ae95edf1b402 (patch) | |
| tree | 55786c094b9e3b0e974c4c076a89969ab3f55307 | |
| parent | 0c2f254bc3d69ba08a59037e8e192d5d7fb7d816 (diff) | |
| download | emacs-9ac033203005ba53c4f1e65fcb44ae95edf1b402.tar.gz emacs-9ac033203005ba53c4f1e65fcb44ae95edf1b402.zip | |
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.
| -rw-r--r-- | ChangeLog | 9 | ||||
| -rwxr-xr-x | build-aux/git-hooks/commit-msg | 39 |
2 files changed, 34 insertions, 14 deletions
| @@ -1,3 +1,12 @@ | |||
| 1 | 2014-12-11 Paul Eggert <eggert@cs.ucla.edu> | ||
| 2 | |||
| 3 | Improve commit-msg messages and autosquash | ||
| 4 | Problem reported by Michal Nazarewicz in Bug#19337. | ||
| 5 | * build-aux/git-hooks/commit-msg: Add "commit message" to | ||
| 6 | diagnostics. Distinguish better between tabs and other | ||
| 7 | unprintable chars in diagnostics. Don't complain if a prefix | ||
| 8 | "fixup! " or "squash! " makes a summary line too long. | ||
| 9 | |||
| 1 | 2014-12-08 Paul Eggert <eggert@cs.ucla.edu> | 10 | 2014-12-08 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 11 | ||
| 3 | Port commit-message checking to FreeBSD 9. | 12 | Port commit-message checking to FreeBSD 9. |
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 |