linux-kernel-mentees.lists.linuxfoundation.org archive mirror
 help / color / mirror / Atom feed
* [Linux-kernel-mentees] [PATCH] checkpatch: GIT_COMMIT_ID: handle commit messages with multiple quotes
@ 2020-09-07 15:14 Ayush
  2020-09-07 20:50 ` Joe Perches
  2020-09-08  8:32 ` Ayush
  0 siblings, 2 replies; 8+ messages in thread
From: Ayush @ 2020-09-07 15:14 UTC (permalink / raw)
  To: apw, joe; +Cc: linux-kernel-mentees, linux-kernel

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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-09-09 13:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 15:14 [Linux-kernel-mentees] [PATCH] checkpatch: GIT_COMMIT_ID: handle commit messages with multiple quotes Ayush
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

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).