Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp518871rdb; Tue, 5 Dec 2023 11:34:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IEy8Es6DA3VzWBPeh8PAzQTvK8rhwNhNS3zghbb6MJiiL8aI/EuxQz35ZWd8aXzZKTm34VJ X-Received: by 2002:a05:6a20:e124:b0:18f:be96:2b7f with SMTP id kr36-20020a056a20e12400b0018fbe962b7fmr561041pzb.84.1701804881068; Tue, 05 Dec 2023 11:34:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701804881; cv=none; d=google.com; s=arc-20160816; b=pNh+Yc71UujGPrSC8Q80gnn7kmfOs2eopZorLkMfEO8AVU7acHyIoiGl9bP8BPVDp0 d6EV2JMPVpPcUD8lbEdf5+PNL6TMpOKMXxGXYlARo6ts+EXcZOgm+vD2F50DBSTyiNBx oOXlwoHKgWg13OHI1uh6b3JFENyhQuNKsmgQh/aToq2IpCWrgsCQdfo79IT6kcJXK/+b X6TN/Q47wLaaoYQ3bOy1X5bLofBdztDiXPotbYyBXHgpYT+4NOKdEYLGcm/ABKuMOjCD xhixAf0KDkpek8BO7DbDrvIzPdCh0zDvs4rSuDZWng7zatOe7flWj8/E/7jRJCNrBK/6 Gaow== 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; bh=DH+XgVFLzsg6pIA+GTRVPaT9W+/c3PIYo1neExH0jWw=; fh=nG+64cWP3XlSl38Ldz2cegDxfWxERSbTAoF2EPS/3kg=; b=Quq8ZYpMBl7jnGSAOSq2G7bMVJWasA+qonkYu3XxC1yiz+r56tPFKhg/DOOdPdySCo Lkse4jKGj3nWqM6azGyVg57S5+E3JzjPgY9QzEPlnKAJLgfyFIk8CqctkTIKjhn+7Wan 44RiIwk8zmUkBxOVuzfQdI7SXGgwFu6piWVUqqq5VPG5Fmk7N501OHzw5Mlnk173qGkz ARPR9t3ydev0/6zdo8keY162BR/6HNPIvYv5e44mEvul5zoL0Wq1cbi6/sOnSqoZhq40 C7YOExo81E+nbCul90C1uXkI/n/hRaoPAJUf1gTyrgYe2Zq5gQotZALMa5sgc6cZee0O hVFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id m22-20020a056a00081600b006ce64b59391si2304014pfk.110.2023.12.05.11.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 11:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 027F780AE203; Tue, 5 Dec 2023 11:34:38 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232023AbjLETeT (ORCPT + 99 others); Tue, 5 Dec 2023 14:34:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229569AbjLETeS (ORCPT ); Tue, 5 Dec 2023 14:34:18 -0500 Received: from andre.telenet-ops.be (andre.telenet-ops.be [IPv6:2a02:1800:120:4::f00:15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB36AB for ; Tue, 5 Dec 2023 11:34:23 -0800 (PST) Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:a051:433:f7fa:99b4]) by andre.telenet-ops.be with bizsmtp id JjaH2B00d0xLcQm01jaHy0; Tue, 05 Dec 2023 20:34:20 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1rAbB6-00B6ne-TW; Tue, 05 Dec 2023 20:34:17 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1rAbBR-002zxt-FN; Tue, 05 Dec 2023 20:34:17 +0100 From: Geert Uytterhoeven To: =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Andy Whitcroft , Joe Perches , Dwaipayan Ray , Lukas Bulwahn , Louis Peens , Philippe Schenker , Simon Horman , Linus Torvalds Cc: Junio C Hamano , linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH] checkpatch: Also accept commit ids with 13-40 chars of sha1 Date: Tue, 5 Dec 2023 20:34:16 +0100 Message-Id: <62f82b0308de05f5aab913392049af15d53c777d.1701804489.git.geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 05 Dec 2023 11:34:38 -0800 (PST) Documentation/dev-tools/checkpatch.rst says: **GIT_COMMIT_ID** The proper way to reference a commit id is: commit <12+ chars of sha1> ("") However, scripts/checkpatch.pl has two different checks: one warning check accepting 12 characters exactly: # Check Fixes: styles is correct Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' and a second error check accepting 12-40 characters: # Check for git id commit length and improperly formed commit descriptions # A correctly formed commit description is: # commit <SHA-1 hash length 12+ chars> ("Complete commit subject") Please use git commit description style 'commit <12+ chars of sha1> Hence patches containing commit ids with more than 12 characters are flagged by checkpatch, and sometimes rejected by maintainers or reviewers. Fix this by aligning the first check with the second check, and with the documentation. Fixes: bd17e036b495bebb ("checkpatch: warn for non-standard fixes tag style") Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- Perhaps the time is ripe to increase the minimum from 12 to 16 chars (in a follow-up patch)? Running git-unique-abbrev[1] on a tree containing v6.7-rc3 and all stable releases gives: 12000853 objects 4: 12000853 / 65536 5: 12000717 / 1048423 6: 6130888 / 2703295 7: 525025 / 260563 8: 33736 / 16861 9: 2106 / 1053 10: 160 / 80 11: 10 / 5 12: 0 / 0 21cf4d54d3c702ac20c6747fa6d4f64dee07dd11 21cf4d54d3ced8a3e752030e483d72997721076d 8a048bbf89528d45c604aed68f7e0f0ef957067d 8a048bbf895b1359e4a33b779ea6d7386cfe4de2 d3ac4e475103c4364ecb47a6a55c114d7c42a014 d3ac4e47510ec0753ebe1e418a334ad202784aa8 d597639e2036f04f0226761e2d818b31f2db7820 d597639e203a100156501df8a0756fd09573e2de ef91b6e893a00d903400f8e1303efc4d52b710af ef91b6e893afc4c4ca488453ea9f19ced5fa5861 12000853 is still smaller than sqrt(16^12) = 16777216, but the safety margin is getting smaller. E.g. my main work tree already contains almost 18M objects. Hence the Birthday Paradox states that collisions of 12 char sha1 values are imminent. Note that we standardized on 12 chars in commit d311cd44545f2f69 ("checkpatch: add test for commit id formatting style in commit log") in v3.17. For comparison, running git-unique-abbrev on a tree with all (upstream + stable) releases from that era gives: 4052307 objects 4: 4052307 / 65536 5: 3966948 / 940963 6: 869691 / 417363 7: 61208 / 30523 8: 3979 / 1989 9: 258 / 129 10: 24 / 12 11: 6 / 3 12: 0 / 0 21cf4d54d3c702ac20c6747fa6d4f64dee07dd11 21cf4d54d3ced8a3e752030e483d72997721076d d597639e2036f04f0226761e2d818b31f2db7820 d597639e203a100156501df8a0756fd09573e2de ef91b6e893a00d903400f8e1303efc4d52b710af ef91b6e893afc4c4ca488453ea9f19ced5fa5861 So the number of objects increased threefold during the last 9 years. Thanks for your comments! [1] https://blog.cuviper.com/2013/11/10/how-short-can-git-abbreviate/ --- scripts/checkpatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 25fdb7fda1128aa9..a4e178a68f6d1d5f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3209,7 +3209,7 @@ sub process { $tag_case = 0 if $tag eq "Fixes:"; $tag_space = 0 if ($line =~ /^fixes:? [0-9a-f]{5,} ($balanced_parens)/i); - $id_length = 0 if ($orig_commit =~ /^[0-9a-f]{12}$/i); + $id_length = 0 if ($orig_commit =~ /^[0-9a-f]{12,40}$/i); $id_case = 0 if ($orig_commit !~ /[A-F]/); # Always strip leading/trailing parens then double quotes if existing @@ -3226,7 +3226,7 @@ sub process { if ($ctitle ne $title || $tag_case || $tag_space || $id_length || $id_case || !$title_has_quotes) { if (WARN("BAD_FIXES_TAG", - "Please use correct Fixes: style 'Fixes: <12 chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) && + "Please use correct Fixes: style 'Fixes: <12+ chars of sha1> (\"<title line>\")' - ie: 'Fixes: $cid (\"$ctitle\")'\n" . $herecurr) && $fix) { $fixed[$fixlinenr] = "Fixes: $cid (\"$ctitle\")"; } -- 2.34.1