Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10418757ybi; Wed, 24 Jul 2019 22:52:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjYqKi48tuBIYlz67GitIYKOyqEcrfdIEpdVBragMfVKoBzXLN4Et1Y+lsY+DVU7h5xbRf X-Received: by 2002:a17:902:42a5:: with SMTP id h34mr92164658pld.16.1564033979802; Wed, 24 Jul 2019 22:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564033979; cv=none; d=google.com; s=arc-20160816; b=MR8LVRgoO3tCEPdVzRfYx3wY/RnLcOYLBhYJISfgwiYDluYPCLf3jIQZ5RFgvHC13q xeemW+bQLojZj1X38w6oPspN0FlBbrzFEw7t8AjeJX+5tVvm5PeiZeeILSEQTJcBWwGg wjAYROfFfELONY89oEPV9cpMg9Jkn8Yy+IjJX4/OmSdZEFUHN02J3Xf2ovNBh0qvnKHS MDfuKVuSPBp+dNfadyABdBMRiWSwvyP+VqcVsC257UwFeTwiYkQ+nH2BivDZv+72m+Ji v56Vuhogzl5f1kyuL+DWqWQWb1yvE3qx1dZNZOkXTAyOjFuWWmQPxSZ0rdFTHVRZEVU+ KH6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=0fSRlveQd6UVJI++kqBkDwrjdIcPlizk1YgZe+2CnhA=; b=p3vR344ueZs+wFkDRQYwDSCuiFpf3Qwq4RVfAXx9XPK4XBF1YNV89tBmAqeGOXPM7e m856qkSlVCoUikxbhgzs/mDmJ1GwjjGFBwYdlCiRSn9MtFuW5ka/q/SK9dhH9J7Vh8RJ SzRXdh9YLKU2w3dpwUC/qg47ThN+/1WFQ842/bB76tgjNP4YpQUiqaeAnXTq8JijnC99 jzxHJIiPINDzxd/t0DsL5sgGJ5CI5yB/tbepUA04MLeaz+1hkBQejHtTtiSxEFon401C E6qaMqwzZbj9GcX/+h/UGMvpIZnHraXTLLGz7FBoYFI7wL2eBMdzjHEbZJveIn46fk/O qTdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HNkSvjs0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bc8si14017362plb.322.2019.07.24.22.52.44; Wed, 24 Jul 2019 22:52:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HNkSvjs0; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389626AbfGYDHK (ORCPT + 99 others); Wed, 24 Jul 2019 23:07:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:55964 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389615AbfGYDHK (ORCPT ); Wed, 24 Jul 2019 23:07:10 -0400 Received: from localhost.localdomain (c-73-223-200-170.hsd1.ca.comcast.net [73.223.200.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D62EF229F4; Thu, 25 Jul 2019 03:07:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564024029; bh=/apw49bWmNuKTrcGODkK1kactakYqDoawBq5nGk1lNg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=HNkSvjs08KMthGYe0CfiWbB9/kL2fb/OLHPJtnHC4wI+1e63pCUourQqnB9LaiDgQ IEMp2OQLzuScBVmusxBDYXnkLBOmix4t2EjScB2i40w1xvj/xcEtWvvmx6uOnfBbJk OArmoWhGs2r7XvvaeLDcTjUpanFtaZK67ZugOIbM= Date: Wed, 24 Jul 2019 20:07:07 -0700 From: Andrew Morton To: Matteo Croce Cc: Joe Perches , LKML , Andy Whitcroft Subject: Re: [PATCH v2] checkpatch.pl: warn on invalid commit id Message-Id: <20190724200707.2ba88e3affd73de1ce64fab6@linux-foundation.org> In-Reply-To: <20190711001640.13398-1-mcroce@redhat.com> References: <20190711001640.13398-1-mcroce@redhat.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 11 Jul 2019 02:16:40 +0200 Matteo Croce wrote: > It can happen that a commit message refers to an invalid commit id, because > the referenced hash changed following a rebase, or simply by mistake. > Add a check in checkpatch.pl which checks that an hash referenced by > a Fixes tag, or just cited in the commit message, is a valid commit id. > > $ scripts/checkpatch.pl <<'EOF' > Subject: [PATCH] test commit > > Sample test commit to test checkpatch.pl > Commit 1da177e4c3f4 ("Linux-2.6.12-rc2") really exists, > commit 0bba044c4ce7 ("tree") is valid but not a commit, > while commit b4cc0b1c0cca ("unknown") is invalid. > > Fixes: f0cacc14cade ("unknown") > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") > EOF > WARNING: Unknown commit id '0bba044c4ce7', maybe rebased or not pulled? > #8: > commit 0bba044c4ce7 ("tree") is valid but not a commit, > > WARNING: Unknown commit id 'b4cc0b1c0cca', maybe rebased or not pulled? > #9: > while commit b4cc0b1c0cca ("unknown") is invalid. > > WARNING: Unknown commit id 'f0cacc14cade', maybe rebased or not pulled? > #11: > Fixes: f0cacc14cade ("unknown") > > total: 0 errors, 3 warnings, 4 lines checked > > ... > > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -2898,6 +2898,17 @@ sub process { > } > } > > +# check for invalid commit id > + if ($in_commit_log && $line =~ /(^fixes:|\bcommit)\s+([0-9a-f]{6,40})\b/i) { > + my $id; > + my $description; > + ($id, $description) = git_commit_info($2, undef, undef); > + if (!defined($id)) { > + WARN("UNKNOWN_COMMIT_ID", > + "Unknown commit id '$2', maybe rebased or not pulled?\n" . $herecurr); > + } > + } > + What does it do if we're not operating in a git directory? For example, I work in /usr/src/25 and my git repo is in ../git26. Also, what happens relatively often is that someone quotes a linux-next or long-term-stable hash. If the user has those trees in the git repo, I assume they won't be informed of the inappropriate hash?