From nobody Thu Sep 18 15:36:52 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC082C4321E for ; Mon, 5 Dec 2022 09:48:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230448AbiLEJsr (ORCPT ); Mon, 5 Dec 2022 04:48:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231509AbiLEJsc (ORCPT ); Mon, 5 Dec 2022 04:48:32 -0500 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D0BA13DDF for ; Mon, 5 Dec 2022 01:48:30 -0800 (PST) Received: by mail-pj1-x1041.google.com with SMTP id hd14-20020a17090b458e00b0021909875bccso10889758pjb.1 for ; Mon, 05 Dec 2022 01:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=sZnwPtKvQW/jye+b9cqc79eHyEu3FBg4FPXfjO+bNBM=; b=opnuKSlgkjT8O+bkJW0QWOW5PCNBodhJhMR0iAGYEdF6Z64dVrVC4au0CUrfTh0g3m 15pViOIu8Q+A74wbXqLNwRGZ7xSI8+QloAVLnjQpaDbDp1KAtTxetUcOgAwF1FGUs+UR /JWbeCOhfx7JlLbKZU5v8smHjLRf8Yrmjb5wdqxMGqcCump9nCSJNSyKshwYFftUii8e 1PdE7VKoR7Bm6BC8I0B6yJtSmO7wbILX0pgpAtAUw5eH6gUUne4hYUvZkddCe2d4CcZ7 XCkAzVJVG6XdE19kP0BUd4tuZh7SdTcybkr9ELtInODRTSr23IPet0m9JbZlcezFarmC zpLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=sZnwPtKvQW/jye+b9cqc79eHyEu3FBg4FPXfjO+bNBM=; b=nSgnDidldvTYZeFwA3QlB+nWxtjmm6gB0KxfkSPByX8NFzchgGPfPG4cTS3nI3e47J MCLRFJbEEKNhlJt7iyPmRNqLE7R5Jxh4kzMqllWWz0We04Pigym9AMskrh6xBPUzCxZJ psMWZsWoThGeQU+LTv02+pBS93m+6DBWfanx/faPSONoq+9rvU7zwJAjHpia9xq4ceuI 3iWG8Pcg0fPOSq72cQva9KonNU1M2fSca67cYMpE0XZFHud+Exy0rei6sau1bGZRkIJL KQD6qjmHQrpgpKzE49kFzuAM0y+Sn6Ll05b7uhL0eEFc6f6BdSKT1KECV1Xyg/yR9YcA A+Ow== X-Gm-Message-State: ANoB5pkekjlnsgY9isFQNtuYJdxMRyJl4OWFjcW34tTuRpVX0/oUkIKb un3oZEVEdTKrS9sbVfe4zcPLVVk6LLapQw== X-Google-Smtp-Source: AA0mqf4rrOennd2qGbQIB0z3GsfXJV4beX3uVs7QyJlzWzsW9y1jbP8+vnrmBRSGnS0Ppq090ms6lA== X-Received: by 2002:a17:903:1015:b0:189:854e:93b1 with SMTP id a21-20020a170903101500b00189854e93b1mr39424065plb.117.1670233710007; Mon, 05 Dec 2022 01:48:30 -0800 (PST) Received: from localhost.localdomain ([43.132.98.43]) by smtp.gmail.com with ESMTPSA id 24-20020a630d58000000b0045751ef6423sm7865083pgn.87.2022.12.05.01.48.28 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 05 Dec 2022 01:48:29 -0800 (PST) From: korantwork@gmail.com To: apw@canonical.com, joe@perches.com, dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com Cc: alexs@kernel.org, linux-kernel@vger.kernel.org, Xinghui Li Subject: [PATCH] checkpatch: Add the backport commit format check Date: Mon, 5 Dec 2022 17:48:26 +0800 Message-Id: <20221205094826.44844-1-korantwork@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Xinghui Li The backport commit has been used to be misreported as Error by checkpatch.pl like this: 'ERROR: Please use git commit description style 'commit <12+ chars of sha1> ("")' - ie:...... commit <sha1> upstream. total: 1 errors, 0 warnings, 8 lines checked ' So, add the backport commit format check to avoid the above mistake. Signed-off-by: Xinghui Li <korantli@tencent.com> --- scripts/checkpatch.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 1e5e66ae5a52..92ba39418239 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3252,6 +3252,10 @@ sub process { # A correctly formed commit description is: # commit <SHA-1 hash length 12+ chars> ("Complete commit subject") # with the commit subject '("' prefix and '")' suffix +# A correctly formed backport commit description is: +# commit <sha1> upstream. +# or +# [ Upstream commit <sha1> ] # This is a fairly compilicated block as it tests for what appears to be # bare SHA-1 hash with minimum length of 5. It also avoids several types= of # possible SHA-1 matches. @@ -3278,6 +3282,7 @@ sub process { my $herectx =3D $herecurr; my $has_parens =3D 0; my $has_quotes =3D 0; + my $backport =3D 0; =20 my $input =3D $line; if ($line =3D~ /(?:\bcommit\s+[0-9a-f]{5,}|\bcommit\s*$)/i) { @@ -3307,18 +3312,21 @@ sub process { $long =3D 1 if ($input =3D~ /\bcommit\s+[0-9a-f]{41,}/i); $space =3D 0 if ($input =3D~ /\bcommit [0-9a-f]/i); $case =3D 0 if ($input =3D~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); + $backport =3D 1 if(($input =3D~ /\bcommit\s+[0-9a-f]{12,40}\supstream/= i) || + ($input =3D~ /\B\[\s[Uu]pstream\scommit\s+[0-9a-f]{5,}\s\]/)); } elsif ($input =3D~ /\b([0-9a-f]{12,40})\b/i) { $orig_commit =3D lc($1); } ($id, $description) =3D git_commit_info($orig_commit, $id, $orig_desc); =20 if (defined($id) && ($short || $long || $space || $case || ($orig_desc ne $description)= || !$has_quotes) && - $last_git_commit_id_linenr !=3D $linenr - 1) { + $last_git_commit_id_linenr !=3D $linenr - 1 + && !$backport) { ERROR("GIT_COMMIT_ID", - "Please use git commit description style 'commit <12+ chars of s= ha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n= " . $herectx); + "Please use git commit description style 'commit <12+ chars of s= ha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n= or check the backport commit description format\n" . $herectx); } #don't report the next line if this line ends in commit and the sha1 ha= sh is the next line $last_git_commit_id_linenr =3D $linenr if ($line =3D~ /\bcommit\s*$/i); --=20 2.27.0