From patchwork Sat Dec 24 15:03:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 36423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp204994wrt; Sat, 24 Dec 2022 07:42:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQ9RC3Teo/kj1i+mHvlZVQxqc01A9yvq5qSHuvdql/QxsIA2PPImPyYVKmZo0mCdmnvzKE X-Received: by 2002:a17:906:688b:b0:7c1:5768:5fc9 with SMTP id n11-20020a170906688b00b007c157685fc9mr9684911ejr.43.1671896574064; Sat, 24 Dec 2022 07:42:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671896574; cv=none; d=google.com; s=arc-20160816; b=wtO759WtXAdGonNH0asR9brkHPMZIFjCq59VZRi+oS9PHV3V1w6kfPKkSVpinscCIW o0xpwIoWRCAf+TaBo7XIdKyn5F5KuqOEid91Ku41eOACdxI5Bqy4MG2f4K2F01XWluM8 w1Cjq00FYKTDoBSllKMBdhp0vBZGRsfgH349gUacN8KSRTJUnlOUCRf5ZQPRsZg0YAT9 ZsWN95edG5PBYU8D3LQIuPyIZXK1hNz+bE92XLDoA/b5wP//LsBZGrmqPPSHE7Eeu9sr dXVPv4g1ThSva7/QI2K3EpKlR7lQj+8aZrXj7wBDC/lEaf4D+yYTDDf0Xut5+9HanuMU fAjA== 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=PwoeT/DZzWJ0RoKpQt8KdQNAhEaP7wxu7BuGJnIsBC4=; b=DdIBNd8vlRfH4ibTfAQJUL8i/oM98VTKPOtmgyL1iroV292zKTREmdfqJKyozQHXcy m32B5aYSPbcogvBhXtLsXd5VDfuFef7LQM7k8Dp+uqre0+9AB/UxNFW7T4ziuZYhaI0t 3sbrQ2AnzWqtoh407eiv1zhSOWLzyhmyqXsnbB1P6QqeMVYkgLZTq0Ityaf8B22sCjoH 1MnwzkpJlmG+ci0vj9qw2BtCz8Z69Bv4IxrTfyg+wnEVQzJEPXXX3Yg39Gb+4PHEiXwM 4bR+AJKRiQvCOC5SJo2D0Xet3fh/YPjADDdEF/sV13VOnqOT8737CNNz26LbBz80N/fF 3Wpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f8Y1KA2d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb7-20020a1709071c8700b007bd6264c2dbsi4922699ejc.28.2022.12.24.07.42.25; Sat, 24 Dec 2022 07:42:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=f8Y1KA2d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231174AbiLXPDw (ORCPT + 99 others); Sat, 24 Dec 2022 10:03:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbiLXPDt (ORCPT ); Sat, 24 Dec 2022 10:03:49 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5A47C5B; Sat, 24 Dec 2022 07:03:48 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4F3C560AB3; Sat, 24 Dec 2022 15:03:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1930C433EF; Sat, 24 Dec 2022 15:03:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671894227; bh=xykcQvAG/P4ufgL8PYGt5jbg4bFNSFnh0UvwTczdshU=; h=From:To:Cc:Subject:Date:From; b=f8Y1KA2dThkOD4efPQ+IwaQnYW3tvOD010DAFGYaxWunYt7dkPovdUpD7ViXoHc57 ezh38a4wUPR75WIZotGJIH5kKF/FnsaeeFJ4usoDO36zmZA6Q5Gd8yL0kSH6ASWVd8 22v1usWprkicVqzjOgmq3867Gr1eOS2rk/D35HQSbYnjO0IDPBv9ryXYC6AAPTbBHl nI8QgnUjcPXzM3cccJlNno4JwqRhGXilmJpfUBEtfMLQBVVjBcV1rcMoDxn/e2z/VO blUq0mnycKrnGczHmd5wOMlMfmqH1qsu2bJcDtYYZTv0jo7drbwmlIcQ4ixAaR8qvz HtaBmVrSOLxjw== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Alex Gaynor , Andrew Davis , Kees Cook , Miguel Ojeda , Wedson Almeida Filho Subject: [PATCH 1/2] .gitinogre: update the command to check tracked files being ignored Date: Sun, 25 Dec 2022 00:03:28 +0900 Message-Id: <20221224150329.394510-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753110621973263976?= X-GMAIL-MSGID: =?utf-8?q?1753110621973263976?= Recent git versions do not accept the noted command. $ git ls-files -i --exclude-standard fatal: ls-files -i must be used with either -o or -c The -c was implied for older git versions, but we need to make it explicit now. Also, replace --exclude-standard with --exclude-per-directory=.gitignore so that everyone will get consistent results. git-ls-files(1) says: --exclude-standard Add the standard Git exclusions: .git/info/exclude, .gitignore in each directory, and the user's global exclusion file. We never know what are locally added to $GIT_DIR/info/exclude or $XDG_CONFIG_HOME/git/ignore. We can only manage .gitignore files committed in the repository. Signed-off-by: Masahiro Yamada --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 3ec73ead6757..2e2e3d1eeaee 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ # subdirectories here. Add them in the ".gitignore" file # in that subdirectory instead. # -# NOTE! Please use 'git ls-files -i --exclude-standard' +# NOTE! Please use 'git ls-files -i -c --exclude-per-directory=.gitignore' # command after changing this file, to see if there are # any tracked files which get ignored after the change. # From patchwork Sat Dec 24 15:03:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 36422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp197583wrt; Sat, 24 Dec 2022 07:21:06 -0800 (PST) X-Google-Smtp-Source: AMrXdXuRGcumFIvTTTXHImE9+TSsnyPk7OHeSma/MNQalunZkYWV2LzBHlI3ldoBz3/tYX8VwtJm X-Received: by 2002:a17:906:184a:b0:78d:f456:1ed0 with SMTP id w10-20020a170906184a00b0078df4561ed0mr15236402eje.33.1671895265921; Sat, 24 Dec 2022 07:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671895265; cv=none; d=google.com; s=arc-20160816; b=myTUsWNtMdLTQZIUGynke7kOIfCqSpji7hKnhwiSjV4s/FuTTUzKuzfJ6ZaU1KHZxd nekmJV6f8b0/bLxyPJDwQgYcLRdl183pdhCY4+p6ewJIIw2wcpWCfmN80144YnuWvdBc 9grUJN6lLmjYlktuorNB/JVWbAfKUSnoXubVuCsBocJIRBrHR2ZeEkqmlYMadBYswT4c 9mQ1ODdHoNX2/HE2cdb4CopnPnsYPGKzuZnOE6uNHipFs1U3BF6DUQNY3cATg+hsKckW zFwKQ8f86/IZGYFQr060Yrbq8fOrIkfrgdUA1FjCVVOGQF/d1t9h6cXi7dEz42uyAqb7 VESA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ERKfEPhHQN9jtXwN3UuiDYWYYqjBCyjQxEoMmzQdlaY=; b=ACNclLfruDyhL1Cl5oDau1GHMXWIOkjNofwk2NDL/naTthnQAy+EEx2AgLCTyU4nDA 1fAEYfjkT+1zXS1fuxCSOLjn1oS3ZXtIcfauQ5SxiqqwaiXQ8eP4CHOqAkMTRKiLm5SP 5asJCNrkzRBMAWZWLLl/1Gd/1Ys9VOv3JCsJqnSTurl3jzHI7a7xdF4YJE+YFJQXQIIV Wqc9XV8tVhRx6fjy9AZpl5WZCC9sjeRAdpGdmraT770ja6jKjkzotfwZrsyfdzFn7r4A W+W3dhIAILGcYDCzI3We/bbg113QbNg6kr74Te48VQhy0luAG7jorSc+K51Uo8JBjqky 6ZrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hTTTSmDM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc13-20020a170907168d00b0083bb359db7dsi5258602ejc.115.2022.12.24.07.20.21; Sat, 24 Dec 2022 07:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=hTTTSmDM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231241AbiLXPDz (ORCPT + 99 others); Sat, 24 Dec 2022 10:03:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbiLXPDx (ORCPT ); Sat, 24 Dec 2022 10:03:53 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10C73C5B; Sat, 24 Dec 2022 07:03:52 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id C6DBBB80066; Sat, 24 Dec 2022 15:03:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 357AAC433F2; Sat, 24 Dec 2022 15:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671894229; bh=CjlCXzFzqTGntNC++T8pagn3RA1Irj/AohxCPANsTBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hTTTSmDMgNimHQaNQ4HjuTxXKzzyTZByktgjMGSvV4JzY6DcBmsSfPid7bodFhyYL nJTHgaLjEnLjRnPt34ZLK9Ueafq5xpPMjDffqvUn6mhaLSnx2U8kQH5VSWkSJWFgS9 IWTefhnwAicRtmiIoYMvsW/Kl1TvEqbqerytQ8hJIQSKZWKlm5pFy42/JgnE1JqEdn UJXn1IJNCsGCQOriWBVYa3QZ1ElNBmLWwGOzFEjHGngs8ZFjFqlPfAsWuWm8O24AjD XQxdpArtSNdcc2zTYuim0YHW6WnWrLSLI7IwK03T8hI2hcaAoXHD8Zj79DmEIR0sdz D1zSOMNd387PQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nathan Chancellor , Nick Desaulniers , Nicolas Schier Subject: [PATCH 2/2] kbuild: make W=1 warn files that are tracked but ignored by git Date: Sun, 25 Dec 2022 00:03:29 +0900 Message-Id: <20221224150329.394510-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221224150329.394510-1-masahiroy@kernel.org> References: <20221224150329.394510-1-masahiroy@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753109250337226783?= X-GMAIL-MSGID: =?utf-8?q?1753109250337226783?= The top .gitignore comments about how to detect files breaking .gitignore rules, but people rarely care about it. Add a new W=1 warning to detect files that are tracked but ignored by git. If git is not installed or the source tree is not tracked by git at all, this script does not print anything. Running it on the v6.1 kernel detected the following: $ make W=1 misc-check Documentation/devicetree/bindings/.yamllint: warning: ignored by one of the .gitignore files drivers/clk/.kunitconfig: warning: ignored by one of the .gitignore files drivers/gpu/drm/tests/.kunitconfig: warning: ignored by one of the .gitignore files drivers/hid/.kunitconfig: warning: ignored by one of the .gitignore files fs/ext4/.kunitconfig: warning: ignored by one of the .gitignore files fs/fat/.kunitconfig: warning: ignored by one of the .gitignore files kernel/kcsan/.kunitconfig: warning: ignored by one of the .gitignore files lib/kunit/.kunitconfig: warning: ignored by one of the .gitignore files mm/kfence/.kunitconfig: warning: ignored by one of the .gitignore files tools/testing/selftests/arm64/tags/.gitignore: warning: ignored by one of the .gitignore files tools/testing/selftests/arm64/tags/Makefile: warning: ignored by one of the .gitignore files tools/testing/selftests/arm64/tags/run_tags_test.sh: warning: ignored by one of the .gitignore files tools/testing/selftests/arm64/tags/tags_test.c: warning: ignored by one of the .gitignore files These are ignored by the '.*' or 'tags' in the top .gitignore, but there is no rule to negate it. You might be tempted to do 'git add -f' but I want to have the real issue fixed (by fixing a .gitignore, or by renaming files, etc.). Signed-off-by: Masahiro Yamada --- Makefile | 6 ++++++ scripts/misc-check | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100755 scripts/misc-check diff --git a/Makefile b/Makefile index 44239352d2bf..b44f46cd55b3 100644 --- a/Makefile +++ b/Makefile @@ -1852,6 +1852,12 @@ rust-analyzer: # Misc # --------------------------------------------------------------------------- +PHONY += misc-check +misc-check: + $(Q)scripts/misc-check + +all: misc-check + PHONY += scripts_gdb scripts_gdb: prepare0 $(Q)$(MAKE) $(build)=scripts/gdb diff --git a/scripts/misc-check b/scripts/misc-check new file mode 100755 index 000000000000..bf68712d1ac1 --- /dev/null +++ b/scripts/misc-check @@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-only + +set -e + +# Detect files that are tracked but ignored by git. This is checked only when +# ${KBUILD_EXTRA_WARN} contains 1, git is installed, and the source tree is +# tracked by git. +check_tracked_ignored_files () { + case "${KBUILD_EXTRA_WARN}" in + *1*) ;; + *) return;; + esac + + git ls-files -i -c --exclude-per-directory=.gitignore 2>/dev/null | + sed 's/$/: warning: ignored by one of the .gitignore files/' >&2 +} + +check_tracked_ignored_files