diff mbox series

[v3] Create a .gitignore file in the CANONICAL_O directory

Message ID 20240214071908.297656-1-yegorslists@googlemail.com
State New
Headers show
Series [v3] Create a .gitignore file in the CANONICAL_O directory | expand

Commit Message

yegorslists--- via buildroot Feb. 14, 2024, 7:19 a.m. UTC
From: Yegor Yefremov <yegorslists@googlemail.com>

This .gitignore file ignores all files in an output directory and
hence doesn't change the git status.

The .gitignore file will be only created if $(O) is a subdirectory
of $(CANONICAL_CURDIR) (aka TOPDIR, but it's only defined later).

Remove "/output" entry from the main .gitignore file as it is already
handled by this general approach.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
Changes v1 -> v2:
    - create .gitignore only if $(O) is a subfolder of $(TOPDIR) (Yann
      E. MORIN)
Changes v2 -> v3:
    - also support nested subdirectories (Yann E. MORIN)

 .gitignore | 1 -
 Makefile   | 7 +++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

--
2.34.1

Comments

Arnout Vandecappelle Feb. 14, 2024, 8:19 a.m. UTC | #1
On 14/02/2024 08:19, yegorslists@googlemail.com wrote:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> This .gitignore file ignores all files in an output directory and
> hence doesn't change the git status.
> 
> The .gitignore file will be only created if $(O) is a subdirectory
> of $(CANONICAL_CURDIR) (aka TOPDIR, but it's only defined later).
> 
> Remove "/output" entry from the main .gitignore file as it is already
> handled by this general approach.
> 
> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
> Changes v1 -> v2:
>      - create .gitignore only if $(O) is a subfolder of $(TOPDIR) (Yann
>        E. MORIN)

  I like to create my output directories as subfolders of my BR2_EXTERNAL. 
Currently I have them in the .gitignore of the BR2_EXTERNAL itself, of course, 
but it would be convenient if they got ignored automatically.

  In other words, I'd like to go back to v1 of this patch. There's no reason, 
ever, to not want an output directory to be gitignored.

  Since two maintainers are disagreeing about this, I guess it's up to the other 
maintainers to pipe up and take a decision?


  Regards,
  Arnout

> Changes v2 -> v3:
>      - also support nested subdirectories (Yann E. MORIN)
> 
>   .gitignore | 1 -
>   Makefile   | 7 +++++++
>   2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/.gitignore b/.gitignore
> index bb02d9f572..14b7ca5040 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -1,4 +1,3 @@
> -/output
>   /dl
>   /.auto.deps
>   /.config.cmd
> diff --git a/Makefile b/Makefile
> index ac625152c6..aea6abb4d3 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -65,6 +65,13 @@ endif
> 
>   CANONICAL_CURDIR = $(realpath $(CURDIR))
> 
> +# Create a default .gitignore file that ignores everything and doesn't make git
> +# repository "dirty". Perform this action only if $(O) is a subdirectory of
> +# $(CANONICAL_CURDIR) (aka TOPDIR, but it's only defined later).
> +ifeq ($(filter-out $(CANONICAL_CURDIR)/%,$(CANONICAL_O)),)
> +$(file >$(CANONICAL_O)/.gitignore,*)
> +endif
> +
>   REQ_UMASK = 0022
> 
>   # Make sure O= is passed (with its absolute canonical path) everywhere the
> --
> 2.34.1
>
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index bb02d9f572..14b7ca5040 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,3 @@ 
-/output
 /dl
 /.auto.deps
 /.config.cmd
diff --git a/Makefile b/Makefile
index ac625152c6..aea6abb4d3 100644
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,13 @@  endif

 CANONICAL_CURDIR = $(realpath $(CURDIR))

+# Create a default .gitignore file that ignores everything and doesn't make git
+# repository "dirty". Perform this action only if $(O) is a subdirectory of
+# $(CANONICAL_CURDIR) (aka TOPDIR, but it's only defined later).
+ifeq ($(filter-out $(CANONICAL_CURDIR)/%,$(CANONICAL_O)),)
+$(file >$(CANONICAL_O)/.gitignore,*)
+endif
+
 REQ_UMASK = 0022

 # Make sure O= is passed (with its absolute canonical path) everywhere the