linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
From: Ayush <ayush@disroot.org>
To: apw@canonical.com, joe@perches.com
Cc: linux-kernel-mentees@lists.linuxfoundation.org,
	linux-kernel@vger.kernel.org
Subject: [Linux-kernel-mentees] [PATCH] checkpatch: GIT_COMMIT_ID: handle commit messages with multiple quotes
Date: Mon,  7 Sep 2020 20:44:17 +0530	[thread overview]
Message-ID: <20200907151417.44453-1-ayush@disroot.org> (raw)

Commits which mentioned/referenced "revert commits" in their description will
get error even if they follow the proper syntax.

for reference:
commit e8a170ff9a35 ("drm/amdgpu: enable -msse2 for GCC 7.1+ users")

This patch checks for quotes inside the commit message and adds it
to $orig_desc.

Earlier, the script just won't update in case of such commit message.
I modified old condition and added new conditions to check possible
patterns.

Following patters are solved (commit taken as example):
- commit 193392ed9f69 ("Revert "drm/amd/display: add -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines"")

- commit 193392ed9f69 ("Revert
"drm/amd/display: add -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines"")

- commit 193392ed9f69 ("Revert "drm/amd/display:
add -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines"")

- commit 193392ed9f69
("Revert "drm/amd/display: add -msse2 to prevent Clang from emitting libcalls to undefined SW FP routines"")

Signed-off-by: Ayush <ayush@disroot.org>
---
 scripts/checkpatch.pl | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 149518d2a6a7..e90e13b013d3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2862,23 +2862,42 @@ sub process {
 				$orig_desc = $1;
 				$hasparens = 1;
 			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i &&
-				 defined $rawlines[$linenr] &&
-				 $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+				 defined $rawlines[$linenr]) {
+				if ($rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) {
+					$orig_desc = $1;
+					$hasparens = 1;
+				} elsif ($rawlines[$linenr] =~ /^\s*\("([^"]+"[^"]+[^"]")"\)/) {
+					$orig_desc = $1;
+					$hasparens = 1;
+				}
+			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+				 defined $rawlines[$linenr]) {
+				$line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i;
 				$orig_desc = $1;
+				if($rawlines[$linenr] =~ /^\s*[^"]+"\)/) {
+					$rawlines[$linenr] =~ /^\s*([^"]+)"\)/;
+					$orig_desc .= " " . $1;
 				$hasparens = 1;
-			} elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i &&
+				} elsif ($rawlines[$linenr] =~ /^\s*"[^"]+""\)/) {
+					$rawlines[$linenr] =~ /^\s*("[^"]+")"\)/;
+					$orig_desc .= " " . $1;
+					$hasparens = 1;
+				}
+			} elsif ($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*[^"]+"\)/) {
-				$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;
 			}
 
 			($id, $description) = git_commit_info($orig_commit,
 							      $id, $orig_desc);

 			if (defined($id) &&
 			   ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) {
 				ERROR("GIT_COMMIT_ID",
-- 
2.28.0

_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

             reply	other threads:[~2020-09-07 15:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-07 15:14 Ayush [this message]
2020-09-07 20:50 ` Joe Perches
2020-09-08  8:32 ` Ayush
2020-09-09 10:06   ` Lukas Bulwahn
2020-09-09 10:31   ` Ayush
2020-09-09 11:32     ` Lukas Bulwahn
2020-09-09 12:02       ` Joe Perches
2020-09-09 13:10         ` Lukas Bulwahn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200907151417.44453-1-ayush@disroot.org \
    --to=ayush@disroot.org \
    --cc=apw@canonical.com \
    --cc=joe@perches.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [Linux-kernel-mentees] [PATCH] checkpatch: GIT_COMMIT_ID: handle commit messages with multiple quotes' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).