Skip to content

Commit 19c146a

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: make sure a commit reference description uses parentheses
The preferred style for a commit reference in a commit log is: commit <foo> ("<title line>") A recent commit removed this check for parentheses. Add it back. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d2e025f commit 19c146a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/checkpatch.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2191,6 +2191,7 @@ sub process {
21912191
my $case = 1;
21922192
my $space = 1;
21932193
my $hasdesc = 0;
2194+
my $hasparens = 0;
21942195
my $id = '0123456789ab';
21952196
my $orig_desc = "commit description";
21962197
my $description = "";
@@ -2201,23 +2202,26 @@ sub process {
22012202
$case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/);
22022203
if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) {
22032204
$orig_desc = $1;
2205+
$hasparens = 1;
22042206
} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
22052207
defined $rawlines[$linenr] &&
22062208
$rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
22072209
$orig_desc = $1;
2210+
$hasparens = 1;
22082211
} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
22092212
defined $rawlines[$linenr] &&
22102213
$rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
22112214
$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
22122215
$orig_desc = $1;
22132216
$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
22142217
$orig_desc .= " " . $1;
2218+
$hasparens = 1;
22152219
}
22162220

22172221
($id, $description) = git_commit_info($orig_commit,
22182222
$id, $orig_desc);
22192223

2220-
if ($short || $long || $space || $case || ($orig_desc ne $description)) {
2224+
if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) {
22212225
ERROR("GIT_COMMIT_ID",
22222226
"Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr);
22232227
}

0 commit comments

Comments
 (0)