All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nicolas Schier <nicolas@fjasle.eu>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>
Subject: Re: [PATCH v2 2/2] kbuild: make W=1 warn files that are tracked but ignored by git
Date: Wed, 28 Dec 2022 17:48:25 +0100	[thread overview]
Message-ID: <Y6xzWV1abXRc/Vf2@bergen.fjasle.eu> (raw)
In-Reply-To: <20221224155138.447912-2-masahiroy@kernel.org>

[-- Attachment #1: Type: text/plain, Size: 3514 bytes --]

On Sun 25 Dec 2022 00:51:38 GMT, Masahiro Yamada wrote:
> 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 <masahiroy@kernel.org>
> ---
> 
> Changes in v2:
>   - Add $(srctree)/ to make it work with O=
> 
>  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..f6ff8f77a669 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -1852,6 +1852,12 @@ rust-analyzer:
>  # Misc
>  # ---------------------------------------------------------------------------
>  
> +PHONY += misc-check
> +misc-check:
> +	$(Q)$(srctree)/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

I like that check.  It doesn't work with O=...; works for me with 
something like:

  git ${abs_srctree:+-C "${abs_srctree}"} ls-files ...

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2022-12-28 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-24 15:51 [PATCH v2 1/2] .gitinogre: update the command to check tracked files being ignored Masahiro Yamada
2022-12-24 15:51 ` [PATCH v2 2/2] kbuild: make W=1 warn files that are tracked but ignored by git Masahiro Yamada
2022-12-24 18:17   ` kernel test robot
2022-12-27  3:57   ` Nathan Chancellor
2022-12-28 16:48   ` Nicolas Schier [this message]
2022-12-29  7:36     ` Masahiro Yamada
2022-12-25 18:37 ` [PATCH v2 1/2] .gitinogre: update the command to check tracked files being ignored Miguel Ojeda

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6xzWV1abXRc/Vf2@bergen.fjasle.eu \
    --to=nicolas@fjasle.eu \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.