History

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.

Joe Perches committed 11 years ago

Commit 2a076f41 parent 0e212e02 files · +11 −2Browse files

Showing the changes to scripts/checkpatch.pl (1 of 2 files). Show all

Unified · Split

scripts/checkpatch.pl+9−0
@@ -1898,6 +1898,7 @@ sub process { · 1897 unmodified lines
18981898
18991899 my $in_header_lines = $file ? 0 : 1;
19001900 my $in_commit_log = 0; #Scanning lines before patch
1901+ my $commit_log_long_line = 0;
19011902 my $reported_maintainer_file = 0;
19021903 my $non_utf8_charset = 0;
19031904
@@ -2233,6 +2234,14 @@ sub process { · 329 unmodified lines
22332234 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
22342235 }
22352236
2237+# Check for line lengths > 75 in commit log, warn once
2238+ if ($in_commit_log && !$commit_log_long_line &&
2239+ length($line) > 75) {
2240+ WARN("COMMIT_LOG_LONG_LINE",
2241+ "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
2242+ $commit_log_long_line = 1;
2243+ }
2244+
22362245 # Check for git id commit length and improperly formed commit descriptions
22372246 if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
22382247 my $init_char = $1;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t