All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Andy Whitcroft <apw@canonical.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] checkpatch: Remove email address comment from email address comparisons
Date: Mon, 10 Feb 2020 10:52:16 -0800	[thread overview]
Message-ID: <ebaa2f7c8f94e25520981945cddcc1982e70e072.camel@perches.com> (raw)
In-Reply-To: <20200207123334.GT14946@hirez.programming.kicks-ass.net>

About 2% of the last 100K commits have email addresses that include an
RFC2822 compliant comment like:

	Peter Zijlstra (Intel) <peterz@infradead.org>

checkpatch currently does a comparison of the complete name and address
to the submitted author to determine if the author has signed-off and
emits a warning if the exact email names and addresses do not match.

Unfortunately, the author email address can be written without the comment
like:

	Peter Zijlstra <peterz@infradead.org>

Add logic to compare the comment stripped email addresses to avoid this
warning.

Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 scripts/checkpatch.pl | 39 +++++++++++++++++++++++++++++----------
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f3b8434..17637d0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1132,6 +1132,7 @@ sub parse_email {
 	my ($formatted_email) = @_;
 
 	my $name = "";
+	my $name_comment = "";
 	my $address = "";
 	my $comment = "";
 
@@ -1164,6 +1165,10 @@ sub parse_email {
 
 	$name = trim($name);
 	$name =~ s/^\"|\"$//g;
+	$name =~ s/(\s*\([^\)]+\))\s*//;
+	if (defined($1)) {
+		$name_comment = trim($1);
+	}
 	$address = trim($address);
 	$address =~ s/^\<|\>$//g;
 
@@ -1172,7 +1177,7 @@ sub parse_email {
 		$name = "\"$name\"";
 	}
 
-	return ($name, $address, $comment);
+	return ($name, $name_comment, $address, $comment);
 }
 
 sub format_email {
@@ -1198,6 +1203,23 @@ sub format_email {
 	return $formatted_email;
 }
 
+sub reformat_email {
+	my ($email) = @_;
+
+	my ($email_name, $name_comment, $email_address, $comment) = parse_email($email);
+	return format_email($email_name, $email_address);
+}
+
+sub same_email_addresses {
+	my ($email1, $email2) = @_;
+
+	my ($email1_name, $name1_comment, $email1_address, $comment1) = parse_email($email1);
+	my ($email2_name, $name2_comment, $email2_address, $comment2) = parse_email($email2);
+
+	return $email1_name eq $email2_name &&
+	       $email1_address eq $email2_address;
+}
+
 sub which {
 	my ($bin) = @_;
 
@@ -2618,17 +2640,16 @@ sub process {
 			$author = $1;
 			$author = encode("utf8", $author) if ($line =~ /=\?utf-8\?/i);
 			$author =~ s/"//g;
+			$author = reformat_email($author);
 		}
 
 # Check the patch for a signoff:
-		if ($line =~ /^\s*signed-off-by:/i) {
+		if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
 			$signoff++;
 			$in_commit_log = 0;
 			if ($author ne '') {
-				my $l = $line;
-				$l =~ s/"//g;
-				if ($l =~ /^\s*signed-off-by:\s*\Q$author\E/i) {
-				    $authorsignoff = 1;
+				if (same_email_addresses($1, $author)) {
+					$authorsignoff = 1;
 				}
 			}
 		}
@@ -2678,7 +2699,7 @@ sub process {
 				}
 			}
 
-			my ($email_name, $email_address, $comment) = parse_email($email);
+			my ($email_name, $name_comment, $email_address, $comment) = parse_email($email);
 			my $suggested_email = format_email(($email_name, $email_address));
 			if ($suggested_email eq "") {
 				ERROR("BAD_SIGN_OFF",
@@ -2689,9 +2710,7 @@ sub process {
 				$dequoted =~ s/" </ </;
 				# Don't force email to have quotes
 				# Allow just an angle bracketed address
-				if ("$dequoted$comment" ne $email &&
-				    "<$email_address>$comment" ne $email &&
-				    "$suggested_email$comment" ne $email) {
+				if (!same_email_addresses($email, $suggested_email)) {
 					WARN("BAD_SIGN_OFF",
 					     "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
 				}



  parent reply	other threads:[~2020-02-10 18:53 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-31 12:45 [PATCH -v2 00/10] Rewrite Motorola MMU page-table layout Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 01/10] m68k,mm: Remove stray nocache in ColdFire pgalloc Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 02/10] m68k,mm: Fix ColdFire pgd_alloc() Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 03/10] m68k,mm: Unify Motorola MMU page setup Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 04/10] m68k,mm: Move the pointer table allocator to motorola.c Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 05/10] m68k,mm: Restructure Motorola MMU page-table layout Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 06/10] m68k,mm: Improve kernel_page_table() Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 07/10] m68k,mm: Use table allocator for pgtables Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 08/10] m68k,mm: Extend table allocator for multiple sizes Peter Zijlstra
2020-02-07 10:56   ` Geert Uytterhoeven
2020-02-07 11:34     ` Peter Zijlstra
2020-02-07 12:11       ` Geert Uytterhoeven
2020-02-07 12:30         ` Checkpatch being daft, Was: " Peter Zijlstra
2020-02-07 12:33           ` Peter Zijlstra
2020-02-09 18:24             ` Joe Perches
2020-02-10 16:38               ` Peter Zijlstra
2020-02-10 17:12                 ` Joe Perches
2020-02-10 18:52             ` Joe Perches [this message]
2020-02-10 22:25               ` [PATCH] checkpatch: Remove email address comment from email address comparisons Andrew Morton
2020-02-10 23:08                 ` Joe Perches
2020-02-07 12:57           ` Checkpatch being daft, Was: [PATCH -v2 08/10] m68k,mm: Extend table allocator for multiple sizes Joe Perches
2020-01-31 12:45 ` [PATCH -v2 09/10] m68k,mm: Fully initialize the page-table allocator Peter Zijlstra
2020-02-07 10:58   ` Geert Uytterhoeven
2020-02-07 11:37     ` Peter Zijlstra
2020-01-31 12:45 ` [PATCH -v2 10/10] m68k,mm: Change ColdFire pgtable_t Peter Zijlstra
2020-01-31 13:19 ` [PATCH -v2 00/10] Rewrite Motorola MMU page-table layout Greg Ungerer
2020-02-03  1:20   ` Greg Ungerer
2020-02-01  8:07 ` Michael Schmitz
2020-02-03  9:50 ` Will Deacon
2020-02-10 11:16 ` Geert Uytterhoeven
2020-03-09 10:15   ` Geert Uytterhoeven
2020-03-09 11:46     ` Peter Zijlstra

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=ebaa2f7c8f94e25520981945cddcc1982e70e072.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.