[PATCH] checkpatch: Add checking if from-author sign-off is last

From: Philipp Bruegmann
Date: Mon Dec 07 2020 - 18:52:31 EST


Print a check if the last Signed-off-by is by the From: author.

submitting-patches.rst states 'the last Signed-off-by: must always be
that of the developer submitting the patch.'.
This patch tries to enforce this, under the assumption that the From:
author is that developer.

Suggested-by: Tobias Langer <langer@xxxxxxxxx>
Co-developed-by: Ferdinand Schober <ferdinand.schober@xxxxxx>
Signed-off-by: Ferdinand Schober <ferdinand.schober@xxxxxx>
Signed-off-by: Philipp Bruegmann <philipp.bruegmann@xxxxxx>
---
scripts/checkpatch.pl | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 7b086d1cd6c2..e1be1d8bfb6e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2447,6 +2447,7 @@ sub process {
my $author = '';
my $authorsignoff = 0;
my $author_sob = '';
+ my $last_sign_off = '';
my $is_patch = 0;
my $is_binding_patch = -1;
my $in_header_lines = $file ? 0 : 1;
@@ -2774,8 +2775,9 @@ sub process {
if ($line =~ /^\s*signed-off-by:\s*(.*)/i) {
$signoff++;
$in_commit_log = 0;
+ $last_sign_off = $1;
if ($author ne '' && $authorsignoff != 1) {
- if (same_email_addresses($1, $author)) {
+ if (same_email_addresses($last_sign_off, $author)) {
$authorsignoff = 1;
} else {
my $ctx = $1;
@@ -7238,7 +7240,7 @@ sub process {
if ($signoff == 0) {
ERROR("MISSING_SIGN_OFF",
"Missing Signed-off-by: line(s)\n");
- } elsif ($authorsignoff != 1) {
+ } else {
# authorsignoff values:
# 0 -> missing sign off
# 1 -> sign off identical
@@ -7252,6 +7254,10 @@ sub process {
if ($authorsignoff == 0) {
ERROR("NO_AUTHOR_SIGN_OFF",
"Missing Signed-off-by: line by nominal patch author '$author'\n");
+ } elsif ($authorsignoff == 1 && $last_sign_off ne $author) {
+ CHK("FROM_SIGN_OFF_NOT_LAST",
+ "Signed-off-by: line by nominal patch author is not the last signature.\n\
+ The author submitting the patch should be signing last.\n");
} elsif ($authorsignoff == 2) {
CHK("FROM_SIGN_OFF_MISMATCH",
"From:/Signed-off-by: email comments mismatch: $sob_msg\n");
--
2.20.1