linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] checkpatch: Warn if missing author Signed-off-by
@ 2018-07-12 10:03 Geert Uytterhoeven
  2018-07-12 10:17 ` Joe Perches
  2018-07-13  6:50 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Geert Uytterhoeven @ 2018-07-12 10:03 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches
  Cc: Jason Gunthorpe, Stephen Rothwell, Linus Walleij,
	Yoshihiro Shimoda, Pavel Machek, linux-kernel,
	Geert Uytterhoeven

Print a warning if none of the Signed-off-by lines cover the patch
author.

Non-ASCII quoted printable encoding in From: headers and (lack of)
double quotes are handled.
Split From: headers are not fully handled: only the first part is
compared.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Tested using a set of ca. 4000 real world commits.

Most common offenders are people using:
  - different email addresses for author and Sob,
  - different firstname/lastname order, or other different name
    spelling,
  - suse.de vs. suse.com.

v3:
  - Also print actual missing author,
  - Match against "\s*" instead of single space,

v2:
  - Use "Encode" instead of "MIME::Words", as the former is a Perl core
    module,
  - Reduce level from error to warning,
---
 scripts/checkpatch.pl | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8d0bad190c25e2e0..d2fd6efe499525c3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -13,6 +13,7 @@ use POSIX;
 use File::Basename;
 use Cwd 'abs_path';
 use Term::ANSIColor qw(:constants);
+use Encode qw(decode encode);
 
 my $P = $0;
 my $D = dirname(abs_path($P));
@@ -2236,6 +2237,8 @@ sub process {
 
 	our $clean = 1;
 	my $signoff = 0;
+	my $author = '';
+	my $authorsignoff = 0;
 	my $is_patch = 0;
 	my $in_header_lines = $file ? 0 : 1;
 	my $in_commit_log = 0;		#Scanning lines before patch
@@ -2518,10 +2521,23 @@ sub process {
 			}
 		}
 
+# Check the patch for a From:
+		if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
+			$author = encode("utf8", $1);
+			$author =~ s/"//g;
+		}
+
 # Check the patch for a signoff:
 		if ($line =~ /^\s*signed-off-by:/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;
+				}
+			}
 		}
 
 # Check if MAINTAINERS is being updated.  If so, there's probably no need to
@@ -6487,9 +6503,14 @@ sub process {
 		ERROR("NOT_UNIFIED_DIFF",
 		      "Does not appear to be a unified-diff format patch\n");
 	}
-	if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
-		ERROR("MISSING_SIGN_OFF",
-		      "Missing Signed-off-by: line(s)\n");
+	if ($is_patch && $has_commit_log && $chk_signoff) {
+		if ($signoff == 0) {
+			ERROR("MISSING_SIGN_OFF",
+			      "Missing Signed-off-by: line(s)\n");
+		} elsif (!$authorsignoff) {
+			WARN("NO_AUTHOR_SIGN_OFF",
+			     "Missing Signed-off-by: line by nominal patch author '$author'\n");
+		}
 	}
 
 	print report_dump();
-- 
2.17.1


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

* Re: [PATCH v3] checkpatch: Warn if missing author Signed-off-by
  2018-07-12 10:03 [PATCH v3] checkpatch: Warn if missing author Signed-off-by Geert Uytterhoeven
@ 2018-07-12 10:17 ` Joe Perches
  2018-07-13  6:50 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Joe Perches @ 2018-07-12 10:17 UTC (permalink / raw)
  To: Geert Uytterhoeven, Andy Whitcroft, Andrew Morton
  Cc: Jason Gunthorpe, Stephen Rothwell, Linus Walleij,
	Yoshihiro Shimoda, Pavel Machek, linux-kernel

On Thu, 2018-07-12 at 12:03 +0200, Geert Uytterhoeven wrote:
> Print a warning if none of the Signed-off-by lines cover the patch
> author.
> 
> Non-ASCII quoted printable encoding in From: headers and (lack of)
> double quotes are handled.
> Split From: headers are not fully handled: only the first part is
> compared.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Thanks Geert.

Acked-by: Joe Perches <joe@perches.com>

> ---
> Tested using a set of ca. 4000 real world commits.
> 
> Most common offenders are people using:
>   - different email addresses for author and Sob,
>   - different firstname/lastname order, or other different name
>     spelling,
>   - suse.de vs. suse.com.
> 
> v3:
>   - Also print actual missing author,
>   - Match against "\s*" instead of single space,
> 
> v2:
>   - Use "Encode" instead of "MIME::Words", as the former is a Perl core
>     module,
>   - Reduce level from error to warning,
> ---
>  scripts/checkpatch.pl | 27 ++++++++++++++++++++++++---
>  1 file changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 8d0bad190c25e2e0..d2fd6efe499525c3 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -13,6 +13,7 @@ use POSIX;
>  use File::Basename;
>  use Cwd 'abs_path';
>  use Term::ANSIColor qw(:constants);
> +use Encode qw(decode encode);
>  
>  my $P = $0;
>  my $D = dirname(abs_path($P));
> @@ -2236,6 +2237,8 @@ sub process {
>  
>  	our $clean = 1;
>  	my $signoff = 0;
> +	my $author = '';
> +	my $authorsignoff = 0;
>  	my $is_patch = 0;
>  	my $in_header_lines = $file ? 0 : 1;
>  	my $in_commit_log = 0;		#Scanning lines before patch
> @@ -2518,10 +2521,23 @@ sub process {
>  			}
>  		}
>  
> +# Check the patch for a From:
> +		if (decode("MIME-Header", $line) =~ /^From:\s*(.*)/) {
> +			$author = encode("utf8", $1);
> +			$author =~ s/"//g;
> +		}
> +
>  # Check the patch for a signoff:
>  		if ($line =~ /^\s*signed-off-by:/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;
> +				}
> +			}
>  		}
>  
>  # Check if MAINTAINERS is being updated.  If so, there's probably no need to
> @@ -6487,9 +6503,14 @@ sub process {
>  		ERROR("NOT_UNIFIED_DIFF",
>  		      "Does not appear to be a unified-diff format patch\n");
>  	}
> -	if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) {
> -		ERROR("MISSING_SIGN_OFF",
> -		      "Missing Signed-off-by: line(s)\n");
> +	if ($is_patch && $has_commit_log && $chk_signoff) {
> +		if ($signoff == 0) {
> +			ERROR("MISSING_SIGN_OFF",
> +			      "Missing Signed-off-by: line(s)\n");
> +		} elsif (!$authorsignoff) {
> +			WARN("NO_AUTHOR_SIGN_OFF",
> +			     "Missing Signed-off-by: line by nominal patch author '$author'\n");
> +		}
>  	}
>  
>  	print report_dump();

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

* Re: [PATCH v3] checkpatch: Warn if missing author Signed-off-by
  2018-07-12 10:03 [PATCH v3] checkpatch: Warn if missing author Signed-off-by Geert Uytterhoeven
  2018-07-12 10:17 ` Joe Perches
@ 2018-07-13  6:50 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2018-07-13  6:50 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: apw, Joe Perches, jgg, Stephen Rothwell, Yoshihiro Shimoda,
	Pavel Machek, linux-kernel

On Thu, Jul 12, 2018 at 12:03 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:

> Print a warning if none of the Signed-off-by lines cover the patch
> author.
>
> Non-ASCII quoted printable encoding in From: headers and (lack of)
> double quotes are handled.
> Split From: headers are not fully handled: only the first part is
> compared.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Tested using a set of ca. 4000 real world commits.
>
> Most common offenders are people using:
>   - different email addresses for author and Sob,
>   - different firstname/lastname order, or other different name
>     spelling,
>   - suse.de vs. suse.com.

Pretty cool patch!
Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

end of thread, other threads:[~2018-07-13  6:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-12 10:03 [PATCH v3] checkpatch: Warn if missing author Signed-off-by Geert Uytterhoeven
2018-07-12 10:17 ` Joe Perches
2018-07-13  6:50 ` Linus Walleij

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