Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp814529ybz; Wed, 29 Apr 2020 09:51:50 -0700 (PDT) X-Google-Smtp-Source: APiQypJirl1RKMQTlKXhAbz8xHx/JVTHmJRS5v++Wx6R3vZ3FoL3xyArAEcGkno7L1HpxYUXNFV/ X-Received: by 2002:a50:d7d3:: with SMTP id m19mr3376519edj.285.1588179110216; Wed, 29 Apr 2020 09:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588179110; cv=none; d=google.com; s=arc-20160816; b=kdv5tmxQCtEW/L1HC8JjntF2hGkVDHv/VBnocP8oRv/B0N8rDueYSFlM7EAzccYfWl WongrZtNbKqG89ua8VEEKRuh4c61li4VDKbebCDXwqrJGmySkqy67V+Q8KQBxx4TiJAD 0esXBmvW4wDWXRsSsOHc9XXdp4+Fkh93G4DHNsKufrLDKQSvAxJq4ML3btNBR5gZpjdX SNwbtKNTU3V+moWHK/Ic0Kgy4T90zMI86zD13Q3lcWPDaE0je0at7U5QR4y2EAG910Nd 210rpFqHmrgIvrCm9wKqz2Xp8OLMm+FRgWbIs6aXtZC4pGnWoLUJba+yMq3hyzRM2sR1 0iQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-transfer-encoding :content-disposition:mime-version:mail-followup-to:message-id :subject:cc:to:from:date:dkim-signature; bh=8olA7bGKpwTL+rub9/QHgnKCc3ZKGK1GWlWeW8QAqvw=; b=GsQIhBSph4tC5py8F4itEmg+Ppi/to7sava74Scn4Kry+F3tGfiokrA3AxHw0SI5cN qnb2c6tnC3cL1hJtsGFqkkZGtmanHdw9TSPnjUpuXvl0HyLru97fqAQmrhzMgAE0zAQr Zds+fAE3pG3uXwdVHVtrGv3ekP2e70sUnLMlUtfAG0p3p98OqfQNKRnXIOFtjSwP2Dso tOkcjRUqct3U+7uv5asbygnIeJLUQxuMdCPVanBVTl7ofc1fGDXXZbyQItxSASQj6Ftx 61WxQxcJlzgen66uXwgtC99XJku3s2dgWJo0m77axKsw6S7kUJLGX2AoS2EIG8xwuEdb y9cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T0jV5NUq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m29si3774596eda.592.2020.04.29.09.51.25; Wed, 29 Apr 2020 09:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=T0jV5NUq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726836AbgD2Qrj (ORCPT + 99 others); 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-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