Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

checkpatch, SubmittingPatches: suggest line wrapping commit messages at 75 columns

Commit messages lines are sometimes overly long.

Suggest line wrapping at 75 columns so the default git commit log
indentation of 4 plus the commit message text still fits on an 80 column
screen.

Add a checkpatch test for long commit messages lines too.

Signed-off-by: Joe Perches <joe@perches.com>
Cc: David Miller <davem@davemloft.net>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Ian Morris <ipm@chirality.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Joe Perches and committed by
Linus Torvalds
2a076f40 0e212e0a

+11 -2
+2 -2
Documentation/SubmittingPatches
··· 614 614 615 615 - An empty line. 616 616 617 - - The body of the explanation, which will be copied to the 618 - permanent changelog to describe this patch. 617 + - The body of the explanation, line wrapped at 75 columns, which will 618 + be copied to the permanent changelog to describe this patch. 619 619 620 620 - The "Signed-off-by:" lines, described above, which will 621 621 also go in the changelog.
+9
scripts/checkpatch.pl
··· 1898 1898 1899 1899 my $in_header_lines = $file ? 0 : 1; 1900 1900 my $in_commit_log = 0; #Scanning lines before patch 1901 + my $commit_log_long_line = 0; 1901 1902 my $reported_maintainer_file = 0; 1902 1903 my $non_utf8_charset = 0; 1903 1904 ··· 2232 2231 if ($in_commit_log && $line =~ /^\s*change-id:/i) { 2233 2232 ERROR("GERRIT_CHANGE_ID", 2234 2233 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); 2234 + } 2235 + 2236 + # Check for line lengths > 75 in commit log, warn once 2237 + if ($in_commit_log && !$commit_log_long_line && 2238 + length($line) > 75) { 2239 + WARN("COMMIT_LOG_LONG_LINE", 2240 + "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr); 2241 + $commit_log_long_line = 1; 2235 2242 } 2236 2243 2237 2244 # Check for git id commit length and improperly formed commit descriptions