Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2275074pxp; Mon, 21 Mar 2022 15:36:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1kOrzuQcjLVqubbMBChP1jOlgewGws+sd/AjXN+Zj9N+3JMLqYyITYew4ACkucx2bhm1u X-Received: by 2002:a62:5343:0:b0:4f7:baad:5c22 with SMTP id h64-20020a625343000000b004f7baad5c22mr25833889pfb.30.1647902208395; Mon, 21 Mar 2022 15:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647902208; cv=none; d=google.com; s=arc-20160816; b=ecrnqwIeBquChpDqqMTwrFhuUEDduZxyoWSvP6NJl+69aPU1TzDXlVKyklJZN0HA4x PdS/A/TGcdPhPzOBEeFmBi5TFgALpAGoB9CwSJZHspnfbcmOwrUVV048d7tEtNHLOWc3 LF8EKdyEnyvja+0wyWpNvPq0uli3XYvEqa0DqvFckkSgLJuXGb22qOkKQk8Dc+3uPN9a psNqu0MbM+fNGRmA66hZ/WPiFIoDu/aHwDbI5KKYw+PnQqGc2hYkV8OV3b2YyxNWJ9/p WScmE/rri4heZLEDFMDFzYTcrcyAPbbM7d1V7W3q9jTvZCXcSP+fC4+fHEtGxahQq33t FBVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=csFbV8mex3SknnrbFvywrMSrr0CsC7QVTDfRrFG7bIc=; b=HrcimmC6UJ47mZtxF3I97PxKx1rOu/tiy3WLuTsfRyM7w/+I7Mvr9zHBiZY927gi4k FGfNofoQV0zO7cPa4CWUAfFiGDn+3xL2Ip44fSpGHhQIhBTFLdPG4zPXYUWcnE5ejnor mTB10amvk42gbmzTZXSey8vIZ3piYQnip9bWnFfdoo9rCLChqgquomFZu75L+5q4plgL /pge1qbDCREI5cZbJgHx4au7SycF3VfbDcTnP2pwGeyHOTbGX/l/vq1N0uRIAsUsUn2i DnI2r9IPU0M0pOhbnvYDq+ueI4xnE920M/Li2EontcHQuEBmg+46AjC2htesM67l8cEe 9+HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RPet5TW1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id t8-20020a056a0021c800b004fa3a8e00c4si9010556pfj.379.2022.03.21.15.36.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 15:36:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RPet5TW1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DD58E3BCADD; Mon, 21 Mar 2022 14:49:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351980AbiCUSHL (ORCPT + 99 others); Mon, 21 Mar 2022 14:07:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345172AbiCUSHJ (ORCPT ); Mon, 21 Mar 2022 14:07:09 -0400 Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97A3C5EDDE for ; Mon, 21 Mar 2022 11:05:43 -0700 (PDT) Received: by mail-oi1-x22f.google.com with SMTP id z8so17062197oix.3 for ; Mon, 21 Mar 2022 11:05:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=csFbV8mex3SknnrbFvywrMSrr0CsC7QVTDfRrFG7bIc=; b=RPet5TW1bR0DE2bWAU0VRzEoOKF0hmUrHqGvQL/S8gHdSwSDeg8xJ5mnbmRb04fKlY E13YRRZ8/UN1VdBu3PoT3SWm3oMlVbfIyEA2i2xCQaxrfkKWkalxP+yPAWnrWrJnag0u XXCzsSJNTRLY36JtE0LjLuoubdR4u/OkR+3E9lXsYrYpzIrLIa42k4JrdPaln6fBJcfh Uc51G5e7zC5A40UWGUxrOUplsoBupbErpXcAw457hLkkBEqCPJ7Cd6Z5Dn9eLf5KDL58 vf6jW4Oaw9kgJjgzSveQml59YIqwHB7JwQxPOnMVzaNST5WZbIsMaSwxPXC/ECiyXhoZ 9r7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=csFbV8mex3SknnrbFvywrMSrr0CsC7QVTDfRrFG7bIc=; b=e9/9K7QAXeZ4bjakbcvF2k0YyoS6EaRU3927yXbWjQ3Cxsd9BiXVcxT5Wuto8+OB37 JjpuAet9DoHCMDsMiEDlVpGjlakdynbNaenSgkGUjnfLJABVkLmfSPlZEIjOLaamp2PS D7Y0S4vdejaoh+nkTv21c2TzK7v5eQR8sZjIoAzUN/qwNKBCWAq+LGv7x2kB1shMpaDb ZSm9dQSJ/BQK2spuNNOnBacqktOAXpQ37CQi9qJpqZOllwCKnlINz4buMJIjyDCsfebs MkpyugNhziowHYvMF3MzzFLXMYxlTMPquQNQRJ4jG3hYyn4526xIZIYeEUapAEmM3Ae3 +mZA== X-Gm-Message-State: AOAM5303QkKEdnVcHllNSrAsvBhfSphASq/Zn8Yoe0SK8eYKs/2G/CfU xR3FedzGERihS34TLCZj5UD72g== X-Received: by 2002:a05:6808:19a6:b0:2d9:c463:fac0 with SMTP id bj38-20020a05680819a600b002d9c463fac0mr179438oib.135.1647885942940; Mon, 21 Mar 2022 11:05:42 -0700 (PDT) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id r129-20020acac187000000b002ef358c6e0esm4086763oif.49.2022.03.21.11.05.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 11:05:42 -0700 (PDT) From: Bjorn Andersson To: Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn Cc: linux-kernel@vger.kernel.org, Stephen Rothwell Subject: [PATCH] checkpatch: Validate "Fixes:" references Date: Mon, 21 Mar 2022 11:07:09 -0700 Message-Id: <20220321180709.1177684-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org checkpatch guards about non-compliant or invalid commit references embedded in the commit message, but a similar set of mistakes can be made when referencing commits in "Fixes:". Add sanity checks for references to missing commits, short hashes, improper spacing, improper case or issues with the commit description. Signed-off-by: Bjorn Andersson --- scripts/checkpatch.pl | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 577e02998701..b602ab50fc5c 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3273,6 +3273,42 @@ sub process { $last_git_commit_id_linenr = $linenr if ($line =~ /\bcommit\s*$/i); } +# Check for valid Fixes: + if ($line =~ /^fixes:\s*([0-9a-f]{5,})/i) { + my $orig_commit = lc($1); + + my $case = 1; + my $short = 1; + my $space = 1; + my $has_quotes = 0; + my $id = '0123456789ab'; + my $orig_desc = "commit description"; + my $description = ""; + + $case = 0 if ($line =~ /^Fixes:\s+[0-9a-f]{5,40}[^A-F]/); + $short = 0 if ($line =~ /\bfixes:\s*[0-9a-f]{12,40}/i); + $space = 0 if ($line =~ /\bfixes: [0-9a-f]{5,} \(/i); + + if ($line =~ /\bfixes:\s+[0-9a-f]{5,}\s*($balanced_parens)/i) { + $orig_desc = substr($1, 1, -1); + if ($orig_desc =~ /^".*"$/) { + $orig_desc = substr($orig_desc, 1, -1); + $has_quotes = 1; + } + } + + ($id, $description) = git_commit_info($orig_commit, + $id, $orig_desc); + + if (defined($id) && ($short || $space || $case || ($orig_desc ne $description) || !$has_quotes)) { + ERROR("GIT_COMMIT_ID", + "Please use git commit description style 'Fixes: <12+ chars of sha1> (\"\")' - ie: 'Fixes: $id (\"$description\")'\n" . $herecurr); + } elsif (!defined($id)) { + WARN("UNKNOWN_COMMIT_ID", + "Unknown commit id '$orig_commit', maybe rebased or not pulled?\n" . $herecurr); + } + } + # Check for added, moved or deleted files if (!$reported_maintainer_file && !$in_commit_log && ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || -- 2.33.1