Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3559499ybz; Mon, 4 May 2020 05:28:41 -0700 (PDT) X-Google-Smtp-Source: APiQypJ+hkAtinmKcb6aDvvuxHIqGpDR5UuusBljHArA3Hrkpa7BkL1npCayHlaNprddd/3zJ5lf X-Received: by 2002:a17:906:11c9:: with SMTP id o9mr14927293eja.64.1588595321113; Mon, 04 May 2020 05:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588595321; cv=none; d=google.com; s=arc-20160816; b=Uj0RK4FHC6di7res6ThfJLnLB3nvg76mCJetWWAs0n2ck2aXGa5VYyQIA6k/i1+TcX FCHiE4hrrJiquCIUK2z7qIelvYGBOLAvUyk5eKzvjXrYv/9K0CLFy9hYQeJcwW0DTPWw ++sr6KJYWsPAQoO0TRMbEqg0814Ck8suFnasDX54Mm66OoQjI1ltR0UIyOvscA6RmndB dp1XhBFsHDJ0hOs00mdLa8GdB/bzZcFW7VVfFN9RgmXxHc//9RmNIhPS5fIAf1P/6+z5 a/VqPuRdQyuVj3+mPDHphye+ivM3LoPWPnNLpqW14TTUNQgPac6zMitUzlgLu3yRvyQc j+SA== 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-disposition :mime-version:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=F4fr9XBi1a/oSkiQzUJpCLmRF7yWLA9/RoAGqLKM65U=; b=uH7w/1lKAbflvnRMLnW73QrHy0ADb0LagdKyPD5LflOa7NSwII1Xj6rFD1z5D1vl0N Rh/d+kj3n8nfmw4cl+fZ6IROt9dRXi4y13akRj3Ok7BcqIh6X+pT8T+LWlKcLcyADtiq hufLOd4elcrIqZj7ALlBHgC80AYTAqYmG3FbjUK+/omRUTM+mXdzbaYZ8P8MQM5nms0r G5QceIQ8G7jv9+eo0pZQPOJTs3KsWbcxEBJWowOafXNinGVcrKXSbeQdV/8Pkhye7bwn NsX5F/oBcu7BFgtJo4e/S/QDZu2EAdKsFa43yHAKmTK3vNL4PC7yihTnuW4SkEbtcHNx nEDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BOMsWwB0; 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 w13si7135559ejj.231.2020.05.04.05.28.13; Mon, 04 May 2020 05:28:41 -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=BOMsWwB0; 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 S1728187AbgEDIhN (ORCPT + 99 others); Mon, 4 May 2020 04:37:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726796AbgEDIhN (ORCPT ); Mon, 4 May 2020 04:37:13 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C095C061A0E; Mon, 4 May 2020 01:37:13 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id t16so6513146plo.7; Mon, 04 May 2020 01:37:13 -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:user-agent; bh=F4fr9XBi1a/oSkiQzUJpCLmRF7yWLA9/RoAGqLKM65U=; b=BOMsWwB01TCxwzPOJoHmTnCHW3jYNKZB7GWyOete9/X0teL4bxx9EaY1d8wFMlGZRA x/ZryFxdEMkl9Acn7n+MkofZ4lRWnfam8m+NiNTvdnq5jYe8HYz8B6YMwHDSXilWa6tb jh5bGQNOYps9Ee02CK3qEEhqTYkRIlkHigUJKpmfVy5zt5unbWIU+CeVXdD+yeMgSW5b 8ow24MtCnBUVyj6OrlD3iNxH6hxZaTTZROgifuOE5QzwN2mw7QGhk8aXqbKyX0fYrq1L YLO9RvWDf9AzAU4CjQQUrZewbchEPC/e0JbRdXNbvfKjE77EhKG5Im8SVZL89k2sjNai ThGw== 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:user-agent; bh=F4fr9XBi1a/oSkiQzUJpCLmRF7yWLA9/RoAGqLKM65U=; b=kIjDV18+DIwhg4cqRcopomzjGvotfFFStY8NQowt+MLrwxEAke2/f5VXoLQSlE7soJ 0BRuMzr7mjOfeoAUsUOKR0W+BPAdcYNDOXW5BFBPw6Ik0TUF5hK6DjI6wlIP38xsTSft LTF4n4pEtQJ21sbSeeOgyW98I8t5bTEHVri+SKqPSAF8/1Dsw9aL9qANgoX4BNCsHv5B T2I2tvG90/LYrw/zzT2MGeiivhPsgHETYIfztHOpUapw/e47N+h3BhUWi8jmxYBDFZa3 iyEHFiC9W8kgtQ4zvASu+EaZocmdbMQUxvuQhQYfTx0vQH1heZ6+ITNkAn9f7gmLlSK/ zLJw== X-Gm-Message-State: AGi0Pub2LlyX2NH9GDjB34oiBN+lez+t8Cz54oR9hmRkLG2zQTzG8xiN b07FmhT/vchhvrOHN1MO2Xs= X-Received: by 2002:a17:90a:68cb:: with SMTP id q11mr16665686pjj.15.1588581432612; Mon, 04 May 2020 01:37:12 -0700 (PDT) Received: from udknight.localhost ([59.57.158.67]) by smtp.gmail.com with ESMTPSA id v7sm8156629pfm.146.2020.05.04.01.37.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2020 01:37:12 -0700 (PDT) Received: from udknight.localhost (localhost [127.0.0.1]) by udknight.localhost (8.14.9/8.14.4) with ESMTP id 0448b726030855; Mon, 4 May 2020 16:37:07 +0800 Received: (from root@localhost) by udknight.localhost (8.14.9/8.14.9/Submit) id 0448b64s030854; Mon, 4 May 2020 16:37:06 +0800 Date: Mon, 4 May 2020 16:37:06 +0800 From: Wang YanQing To: joe@perches.com Cc: Andy Whitcroft , linux-kernel@vger.kernel.org, Alexei Starovoitov , Matteo Croce , Markus.Elfring@web.de, kernel-janitors@vger.kernel.org Subject: [PATCH v2] checkpatch: allow commit description spans across three lines Message-ID: <20200504083706.GA30290@udknight> Mail-Followup-To: Wang YanQing , joe@perches.com, Andy Whitcroft , linux-kernel@vger.kernel.org, Alexei Starovoitov , Matteo Croce , Markus.Elfring@web.de, kernel-janitors@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 The current GIT_COMMIT_ID will report error when the commit description spans across three lines, for examples: "... To rehash a previous explanation given in commit 1c44ce560b4d ("net: mscc: ocelot: fix vlan_filtering when enslaving to bridge before link is up"), the switch driver operates the in a mode where a single VLAN can be transmitted as untagged on a particular egress port. That is the "native VLAN on trunk port" use case. ..." The above changelog comes from commit 87b0f983f66f ("net: mscc: ocelot: fix untagged packet drops when enslaving to vlan aware bridge"). "... With the optimizations for TLB invalidation from commit 0cef77c7798a ("powerpc/64s/radix: flush remote CPUs out of single-threaded mm_cpumask"), the scope of a TLBI (global vs. local) can now be ..." The above changelog comes from commit cca19f0b684f ("powerpc/64s/radix: Fix missing global invalidations when removing copro"). The total length of commit description ("commit"+"12+ SHA1"+("title line")) exceeds 85 isn't uncommon thing, and it isn't uncommon thing that the ~85 characters span across three lines, see above examples. This patch adds support to recognize commit description which spans across three lines, then it will not emit error message for such situation. Signed-off-by: Wang YanQing --- Hi! Joe I have tested with below command: git log -10000 --format=%H -i --grep=" commit " | \ while read commit ; do \ echo $commit; \ ./scripts/checkpatch.pl --git $commit --types=GIT_COMMIT_ID --quiet --nosummary --color=never; \ done There are ~50 properly formed commit descriptions belong to this class, and I haven't check for the non-standard commit descriptions, for examples: 3403e56b41c176f6531a2a6d77d85b46fa34169c a78945c357f58665d6a5da8a69e085898e831c70 87b0f983f66f23762921129fd35966eddc3f2dae ac8517440344dbe598f7c1c23e686c800b563061 cca19f0b684f4ed6aabf6ad07ae3e15e77bfd78a 53406ed1bcfdabe4b5bc35e6d17946c6f9f563e2 This number isn't big, but they are all in properly formed format, so I think we should support them and avoid emitting false positive error report. v2: 1: Reword the title line. 2: Reword the changelog. 3: Rewrite the implementation. scripts/checkpatch.pl | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ef34716..8cfc3a9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2900,6 +2900,16 @@ sub process { $rawlines[$linenr] =~ /^\s*\("(.+)"\)/) { $orig_desc = $1; $has_parens_and_dqm = 1; + } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && + defined $rawlines[$linenr] && + $rawlines[$linenr] =~ /^\s*\(".+$/ && + defined $rawlines[$linenr + 1] && + $rawlines[$linenr + 1] =~ /^\s*.+"\)/) { + $rawlines[$linenr] =~ /^\s*\("(.+)$/i; + $orig_desc = $1; + $rawlines[$linenr + 1] =~ /^\s*(.+)"\)/; + $orig_desc .= " " . $1; + $has_parens_and_dqm = 1; } elsif ($line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\(".+$/i && defined $rawlines[$linenr] && $rawlines[$linenr] =~ /^\s*.+"\)/) { @@ -2913,12 +2923,29 @@ sub process { $acrosslines = 1; $diagnostics .= "The $name spans across lines.\n"; } + } elsif ($line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\(".+$/i && + defined $rawlines[$linenr] && + $rawlines[$linenr] !~ /^\s*.+"\)/ && + defined $rawlines[$linenr + 1] && + $rawlines[$linenr + 1] =~ /^\s*.+"\)/) { + $line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\("(.+)$/i; + $orig_desc = $1; + $rawlines[$linenr] =~ /^\s*(.+)/; + $orig_desc .= " " . $1; + $rawlines[$linenr + 1] =~ /^\s*(.+)"\)/; + $orig_desc .= " " . $1; + $has_parens_and_dqm = 1; + + if ($prefix eq "Fixes:") { + $acrosslines = 1; + $diagnostics .= "The $name spans across lines.\n"; + } } elsif (($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && defined $rawlines[$linenr] && $rawlines[$linenr] =~ /^\s*\("/) || $line =~ /\b$prefix\s+[0-9a-f]{5,}\s+\(".+$/i) { $diagnostics .= "Missing right '\")' at the end of title line?\n"; - $diagnostics .= "The $name spans across more than two lines?\n"; + $diagnostics .= "The $name spans across more than three lines?\n"; } elsif ($hasprefix && !$space2) { $diagnostics .= "No title line in '(\"<$title>\")' format is found.\n"; } -- 1.8.5.6.2.g3d8a54e.dirty