* [PATCH v2 1/2] .gitinogre: update the command to check tracked files being ignored
@ 2022-12-24 15:51 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-25 18:37 ` [PATCH v2 1/2] .gitinogre: update the command to check tracked files being ignored Miguel Ojeda
0 siblings, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-12-24 15:51 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Alex Gaynor, Andrew Davis,
Kees Cook, Miguel Ojeda, Wedson Almeida Filho
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 <masahiroy@kernel.org>
---
(no changes since v1)
.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.
#
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH v2 2/2] kbuild: make W=1 warn files that are tracked but ignored by git
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 ` Masahiro Yamada
2022-12-27 3:57 ` Nathan Chancellor
2022-12-28 16:48 ` Nicolas Schier
2022-12-25 18:37 ` [PATCH v2 1/2] .gitinogre: update the command to check tracked files being ignored Miguel Ojeda
1 sibling, 2 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-12-24 15:51 UTC (permalink / raw)
To: linux-kbuild
Cc: linux-kernel, Masahiro Yamada, Nathan Chancellor,
Nick Desaulniers, Nicolas Schier
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
+}
+
+check_tracked_ignored_files
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/2] kbuild: make W=1 warn files that are tracked but ignored by git
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-27 3:57 ` Nathan Chancellor
2022-12-28 16:48 ` Nicolas Schier
1 sibling, 0 replies; 6+ messages in thread
From: Nathan Chancellor @ 2022-12-27 3:57 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Nick Desaulniers, Nicolas Schier
On Sun, Dec 25, 2022 at 12:51:38AM +0900, 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>
Reviewed-by: Nathan Chancellor <nathan@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
> +}
> +
> +check_tracked_ignored_files
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/2] kbuild: make W=1 warn files that are tracked but ignored by git
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-27 3:57 ` Nathan Chancellor
@ 2022-12-28 16:48 ` Nicolas Schier
2022-12-29 7:36 ` Masahiro Yamada
1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Schier @ 2022-12-28 16:48 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers
[-- 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 --]
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH v2 2/2] kbuild: make W=1 warn files that are tracked but ignored by git
2022-12-28 16:48 ` Nicolas Schier
@ 2022-12-29 7:36 ` Masahiro Yamada
0 siblings, 0 replies; 6+ messages in thread
From: Masahiro Yamada @ 2022-12-29 7:36 UTC (permalink / raw)
To: Nicolas Schier
Cc: linux-kbuild, linux-kernel, Nathan Chancellor, Nick Desaulniers
On Thu, Dec 29, 2022 at 1:48 AM Nicolas Schier <nicolas@fjasle.eu> wrote:
>
> 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 ...
A good catch!
I will fix it in v3.
Thanks.
>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] .gitinogre: update the command to check tracked files being ignored
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-25 18:37 ` Miguel Ojeda
1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2022-12-25 18:37 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-kbuild, linux-kernel, Alex Gaynor, Andrew Davis, Kees Cook,
Miguel Ojeda, Wedson Almeida Filho
On Sat, Dec 24, 2022 at 4:51 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> The -c was implied for older git versions, but we need to make it
> explicit now.
Perhaps add a `Link:` to Git's commit b338e9f66873 ("ls-files: error
out on -i unless -o or -c are specified")
https://git.kernel.org/pub/scm/git/git.git/commit/?id=b338e9f668737e08201c990450b8c3d744f63162
> We never know what are locally added to $GIT_DIR/info/exclude or
> $XDG_CONFIG_HOME/git/ignore.
Perhaps we could say "global exclusion file" instead (since it could
be the one from `core.excludesFile` too).
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
By the way, in the commit title: "gitinogre" -> "gitignore"
Reviewed-by: Miguel Ojeda <ojeda@kernel.org>
Cheers,
Miguel
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-12-29 7:38 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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-27 3:57 ` Nathan Chancellor
2022-12-28 16:48 ` Nicolas Schier
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox