From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A605CC83004 for ; Wed, 29 Apr 2020 16:47:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7AC7F208FE for ; Wed, 29 Apr 2020 16:47:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T0jV5NUq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726883AbgD2Qrj (ORCPT ); Wed, 29 Apr 2020 12:47:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726456AbgD2Qrj (ORCPT ); Wed, 29 Apr 2020 12:47:39 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 297EDC03C1AE; Wed, 29 Apr 2020 09:47:39 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t7so1048627plr.0; Wed, 29 Apr 2020 09:47:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=8olA7bGKpwTL+rub9/QHgnKCc3ZKGK1GWlWeW8QAqvw=; b=T0jV5NUqXAu2hp6WbcE9MU1kfF1Ua+DMHNF3Rtd5h7juQf1Z1B7R6LiywelnQcCA8B 6zw0kbjbuuXVI4UhD1F0CbXny+nv1341VtVGzs/0fDgWyLQBTr4tPqACNY7f/+Z7TK24 prgG+YEeDbNVmy96ptsNvv7gxdcSSsUSLnnEgZrV3tYEhPQ1Y5u/n6pEU0/2WfHerW9g FXPSRBikIj7c9oMR+69kKn26CWJ7d1QgaurhsHFSZ3gX1S70P13D0JD0eFc5CrKzYnKi 1mxFj9zj5CBCg/cNLbE63m0VnP8qgXDBu5gqgc2VOGKIhXquHhZUl1C8NgHKb6xDYfxs 2L2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=8olA7bGKpwTL+rub9/QHgnKCc3ZKGK1GWlWeW8QAqvw=; b=NBGghtMdM3ne76XIx07qZI3YZXD8O+mUnqjrX3UvIJtpopPjtxOqZGHTmhOUjIJNm7 acL7FPSNFutHUMY8mIgdrVn3gAOq+mLnooksY28P/0JQExmZ+F1xq9QiECLeSFIz+yaM v6J+57tB+cqkD3/MlQOFOCrFrp1UVMgUNfleeOGS4/P9fJp1orjVdB4wBsJhNNjzIVSU bwGvbzlOXakCVXCI8SoXLIKiMy70vswH0b2uYCK1slwhUkmeWJbdQ2EhFPPFRtAhgXk5 Oa207n7VE98GOorSWBvYQ/oTAgldMudv2mCohBwzU2i/VMijxfRsjwNIS5vHOgyGNJbf YjaA== X-Gm-Message-State: AGi0PuZK/SSY9BDh4ov3CSTy1V7rYQxRlnC2bN6RO/GihAaJB9TSzemo 6xclGJNrJF64Htn2qVOiUnIZLYcz X-Google-Smtp-Source: APiQypJ9G7U5RXGrBLrAmF7yA+s0D+9dvzXHBw/pRM833NET1oopuLWJ5EBedBsfc0sfi2RR+KuGXQ== X-Received: by 2002:a17:90a:b884:: with SMTP id o4mr4222432pjr.8.1588178858520; Wed, 29 Apr 2020 09:47:38 -0700 (PDT) Received: from udknight.localhost ([59.57.158.27]) by smtp.gmail.com with ESMTPSA id w11sm1425302pgj.4.2020.04.29.09.47.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Apr 2020 09:47:37 -0700 (PDT) Received: from udknight.localhost (localhost [127.0.0.1]) by udknight.localhost (8.14.9/8.14.4) with ESMTP id 03TGapvt013853; Thu, 30 Apr 2020 00:36:51 +0800 Received: (from root@localhost) by udknight.localhost (8.14.9/8.14.9/Submit) id 03TGaj5E013847; Thu, 30 Apr 2020 00:36:45 +0800 Date: Thu, 30 Apr 2020 00:36:45 +0800 From: Wang YanQing To: joe@perches.com Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Alexei Starovoitov , Andy Whitcroft , Markus.Elfring@web.de, mcroce@redhat.com Subject: [PATCH] checkpatch: add support to check 'Fixes:' tag format Message-ID: <20200429163645.GA13810@udknight> Mail-Followup-To: Wang YanQing , joe@perches.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Alexei Starovoitov , Andy Whitcroft , Markus.Elfring@web.de, mcroce@redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to submitting-patches.rst, 'Fixes:' tag has a little stricter condition about the one line summary than normal git commit description: “... Do not split the tag across multiple lines, tags are exempt from the "wrap at 75 columns" rule in order to simplify parsing scripts ...” And there is no sanity check for 'Fixes:' tag format in checkpatch the same as GIT_COMMIT_ID for git commit description, so let's expand the GIT_COMMIT_ID to add 'Fixes:' tag format check support. Based on original patch by Joe Perches Link: https://lore.kernel.org/lkml/40bfc40958fca6e2cc9b86101153aa0715fac4f7.camel@perches.com/ Signed-off-by: Wang YanQing --- scripts/checkpatch.pl | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 23a001a..879dcf4 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2818,11 +2818,13 @@ sub process { $line !~ /^\s*(?:Link|Patchwork|http|https|BugLink|base-commit):/i && $line !~ /^This reverts commit [0-9a-f]{7,40}/ && ($line =~ /\bcommit\s+[0-9a-f]{5,}\b/i || + $line =~ /\bfixes:\s+[0-9a-f]{5,}\b/i || ($line =~ /(?:\s|^)[0-9a-f]{12,40}(?:[\s"'\(\[]|$)/i && - $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i && - $line !~ /\bfixes:\s*[0-9a-f]{12,40}/i))) { + $line !~ /[\<\[][0-9a-f]{12,40}[\>\]]/i))) { my $init_char = "c"; my $orig_commit = ""; + my $prefix = "commit"; + my $prefix_case = "[Cc]ommit"; my $short = 1; my $long = 0; my $case = 1; @@ -2832,19 +2834,28 @@ sub process { my $id = '0123456789ab'; my $orig_desc = "commit description"; my $description = ""; + my $acrosslines = 0; + my $title = "title line"; - if ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) { + if ($line =~ /\b(f)ixes:\s+([0-9a-f]{5,})\b/i) { + $init_char = $1; + $orig_commit = lc($2); + $prefix = "Fixes:"; + $prefix_case = "Fixes:"; + $init_char = "F"; + $title = "a single line title (without line breaks)"; + } elsif ($line =~ /\b(c)ommit\s+([0-9a-f]{5,})\b/i) { $init_char = $1; $orig_commit = lc($2); } elsif ($line =~ /\b([0-9a-f]{12,40})\b/i) { $orig_commit = lc($1); } - $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i); - $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i); - $space = 0 if ($line =~ /\bcommit [0-9a-f]/i); - $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); - if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) { + $short = 0 if ($line =~ /\b$prefix\s+[0-9a-f]{12,40}/i); + $long = 1 if ($line =~ /\b$prefix\s+[0-9a-f]{41,}/i); + $space = 0 if ($line =~ /\b$prefix [0-9a-f]/i); + $case = 0 if ($line =~ /\b$prefix_case\s+[0-9a-f]{5,40}[^A-F]/); + if ($line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) { $orig_desc = $1; $hasparens = 1; } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && @@ -2852,23 +2863,24 @@ sub process { $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) { $orig_desc = $1; $hasparens = 1; - } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i && + } elsif ($line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\("[^"]+$/i && defined $rawlines[$linenr] && $rawlines[$linenr] =~ /^\s*[^"]+"\)/) { - $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i; + $line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\("([^"]+)$/i; $orig_desc = $1; $rawlines[$linenr] =~ /^\s*([^"]+)"\)/; $orig_desc .= " " . $1; $hasparens = 1; + $acrosslines = 1 if ($prefix eq "Fixes:"); } ($id, $description) = git_commit_info($orig_commit, $id, $orig_desc); if (defined($id) && - ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens)) { + ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens || $acrosslines)) { ERROR("GIT_COMMIT_ID", - "Please use git commit description style 'commit <12+ chars of sha1> (\"\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr); + "Please use git commit description style '$prefix <12+ chars of sha1> (\"<$title>\")' - ie: '${init_char}" . substr($prefix, 1) . " $id (\"$description\")'\n" . $herecurr); } } -- 1.8.5.6.2.g3d8a54e.dirty