From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758944AbcG1ByI (ORCPT ); Wed, 27 Jul 2016 21:54:08 -0400 Received: from mail-qk0-f196.google.com ([209.85.220.196]:33221 "EHLO mail-qk0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755435AbcG1Bx7 (ORCPT ); Wed, 27 Jul 2016 21:53:59 -0400 From: Allen Hubbe To: linux-kernel@vger.kernel.org, Andy Whitcroft , Joe Perches Cc: Allen Hubbe Subject: [PATCH v2] checkpatch: check signoff when reading stdin Date: Wed, 27 Jul 2016 21:53:53 -0400 Message-Id: <48be31e414bddc65bccfa6b1322359be9ba032eb.1469670589.git.allenbh@gmail.com> X-Mailer: git-send-email 2.9.1 In-Reply-To: <5e6441a147be1d796620d1e302e1c73daa8c0b86.1469656370.git.allenbh@gmail.com> References: <5e6441a147be1d796620d1e302e1c73daa8c0b86.1469656370.git.allenbh@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signoff was not checked if the filename is '-', indicating reading the patch from stdin. Commands such as the below would not warn about a missing signoff, because the patch filename is '-'. This change allows checkpatch to warn about a missing signoff, even if the input filename is '-', but only if the patch has a commit message. git show --pretty=email | scripts/checkpatch.pl - A more common use of checkpatch with stdin is for piping git diff through checkpatch. The diff output would not contain a commit message, and therefore it would not contain a signoff line. For this common use case, a warning should not be printed about the missing signoff. With this change we will only warn about a missing signoff if the input contains a commit message. git diff | scripts/checkpatch.pl - Before this patch, a workaround for the first command was to refer to stdin by a name other than '-'. The workaround is not an elegant solution, because elsewhere checkpatch uses the fact that filename equals '-', such as in setting '$vname' to 'Your patch' for stdin. The command below would report "/dev/stdin has style problems" instead of "Your patch has style problems." git show --pretty=email | scripts/checkpatch.pl /dev/stdin Signed-off-by: Allen Hubbe --- scripts/checkpatch.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4904ced676d4..9be0343baa77 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2064,6 +2064,7 @@ sub process { my $is_patch = 0; my $in_header_lines = $file ? 0 : 1; my $in_commit_log = 0; #Scanning lines before patch + my $has_commit_log = 0; #Encountered lines before patch my $commit_log_possible_stack_dump = 0; my $commit_log_long_line = 0; my $commit_log_has_diff = 0; @@ -2561,6 +2562,7 @@ sub process { $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) { $in_header_lines = 0; $in_commit_log = 1; + $has_commit_log = 1; } # Check if there is UTF-8 in a commit log when a mail header has explicitly @@ -6045,7 +6047,7 @@ sub process { ERROR("NOT_UNIFIED_DIFF", "Does not appear to be a unified-diff format patch\n"); } - if ($is_patch && $filename ne '-' && $chk_signoff && $signoff == 0) { + if ($is_patch && $has_commit_log && $chk_signoff && $signoff == 0) { ERROR("MISSING_SIGN_OFF", "Missing Signed-off-by: line(s)\n"); } -- 2.9.1