From 508a6c80d7d04db0d68f8c3a4202937e1049281c Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Thu, 8 Oct 2020 18:53:58 -0700 Subject: [PATCH] checkpatch: Handle quotes within commit reference descriptions Checkpatch tests that commit references follow the format: commit 19c146a64c5e ("checkpatch: make sure a commit reference description uses parentheses") If a commit is a revert commit, its title line is frequently like: Revert "checkpatch: make sure a commit reference uses parantheses" Checkpatch doesn't handle quotation marks in commit message properly, so use a lookahead to detect the "), which is less frequently found in commit message title lines. Since a lookahead is used, commits with ") in the title line, such as commit 8ac68dc455d9 ("revert: 1320a4052ea1 ("audit: trigger accompanying records when no rules present")"), is handled properly. There is at least one case not properly handled, where the title spans two lines and there is a ") on the first line. There are approximately 5 such possible commits on 5.9-rc8. Change-Id: Ia3355103aa6d15d4109fa11155d07b14bd7d9f0f Signed-off-by: Elliot Berman --- scripts/checkpatch.pl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 940b639e5c54..a9896923254d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2986,20 +2986,20 @@ sub process { $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i); $space = 0 if ($line =~ /\bcommit [0-9a-f]/i); $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); - if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) { + if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)(?="\))/i) { $orig_desc = $1; $hasparens = 1; } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && defined $rawlines[$linenr] && - $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) { + $rawlines[$linenr] =~ /^\s*\("(.+)(?="\))/) { $orig_desc = $1; $hasparens = 1; - } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i && + } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\(".+(?!"\))$/i && defined $rawlines[$linenr] && - $rawlines[$linenr] =~ /^\s*[^"]+"\)/) { - $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i; + $rawlines[$linenr] =~ /^\s*.+(?<="\))/) { + $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("(.+)$/i; $orig_desc = $1; - $rawlines[$linenr] =~ /^\s*([^"]+)"\)/; + $rawlines[$linenr] =~ /^\s*(.+)(?="\))/; $orig_desc .= " " . $1; $hasparens = 1; }