diff mbox series

Create a .gitignore file in the CANONICAL_O directory

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

Commit Message

yegorslists--- via buildroot Feb. 6, 2024, 1:20 p.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.

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>
---
 .gitignore | 1 -
 Makefile   | 3 +++
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Yann E. MORIN Feb. 6, 2024, 1:30 p.m. UTC | #1
Yegor, All,

On 2024-02-06 14:20 +0100, yegorslists--- via buildroot spake thusly:
> From: Yegor Yefremov <yegorslists@googlemail.com>
> 
> This .gitignore file ignores all files in an output directory and
> hence doesn't change the git status.
> 
> Remove "/output" entry from the main .gitignore file as it is already
> handled by this general approach.

What are you trying to achieve with this that does not work currently?

Regards,
Yann E. MORIN.

> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> ---
>  .gitignore | 1 -
>  Makefile   | 3 +++
>  2 files changed, 3 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..86d4444745 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -63,6 +63,9 @@ ifneq ($(findstring @,$(CANONICAL_O)),)
>  $(error The build directory can not contain a '@')
>  endif
>  
> +# Create a default .gitignore file that ignores everything
> +$(shell echo "*" > "$(CANONICAL_O)/.gitignore")
> +
>  CANONICAL_CURDIR = $(realpath $(CURDIR))
>  
>  REQ_UMASK = 0022
> -- 
> 2.34.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot
Arnout Vandecappelle Feb. 6, 2024, 1:37 p.m. UTC | #2
On 06/02/2024 14:30, Yann E. MORIN wrote:
> Yegor, All,
> 
> On 2024-02-06 14:20 +0100, yegorslists--- via buildroot spake thusly:
>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>
>> This .gitignore file ignores all files in an output directory and
>> hence doesn't change the git status.
>>
>> Remove "/output" entry from the main .gitignore file as it is already
>> handled by this general approach.
> 
> What are you trying to achieve with this that does not work currently?

  I you do `make O=output-test-mypkg` (which I do quite a lot), that output 
directory doesn't get ignored by git. We could ignore output* but maybe you name 
the output directory o-foo or something.

  Putting a .gitignore in a generated directory is a very elegant solution for 
that. It is used by e.g. virtualenv, pytest, and a load of other applications 
that generate output in a directory.

  Since the .gitignore is created in the output directory, it is no longer 
necessary to put output/ in the .gitignore file.


  All of the above could be put in the commit message, of course, but for me 
Yegor's commit message was sufficiently clear :-)

  Regards,
  Arnout


> 
> Regards,
> Yann E. MORIN.
> 
>> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
>> ---
>>   .gitignore | 1 -
>>   Makefile   | 3 +++
>>   2 files changed, 3 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..86d4444745 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -63,6 +63,9 @@ ifneq ($(findstring @,$(CANONICAL_O)),)
>>   $(error The build directory can not contain a '@')
>>   endif
>>   
>> +# Create a default .gitignore file that ignores everything
>> +$(shell echo "*" > "$(CANONICAL_O)/.gitignore")
>> +
>>   CANONICAL_CURDIR = $(realpath $(CURDIR))
>>   
>>   REQ_UMASK = 0022
>> -- 
>> 2.34.1
>>
>> _______________________________________________
>> buildroot mailing list
>> buildroot@buildroot.org
>> https://lists.buildroot.org/mailman/listinfo/buildroot
>
Yegor Yefremov Feb. 12, 2024, 9 a.m. UTC | #3
Hi Yann,

On Tue, Feb 6, 2024 at 2:37 PM Arnout Vandecappelle <arnout@mind.be> wrote:
>
>
>
> On 06/02/2024 14:30, Yann E. MORIN wrote:
> > Yegor, All,
> >
> > On 2024-02-06 14:20 +0100, yegorslists--- via buildroot spake thusly:
> >> From: Yegor Yefremov <yegorslists@googlemail.com>
> >>
> >> This .gitignore file ignores all files in an output directory and
> >> hence doesn't change the git status.
> >>
> >> Remove "/output" entry from the main .gitignore file as it is already
> >> handled by this general approach.
> >
> > What are you trying to achieve with this that does not work currently?
>
>   I you do `make O=output-test-mypkg` (which I do quite a lot), that output
> directory doesn't get ignored by git. We could ignore output* but maybe you name
> the output directory o-foo or something.
>
>   Putting a .gitignore in a generated directory is a very elegant solution for
> that. It is used by e.g. virtualenv, pytest, and a load of other applications
> that generate output in a directory.
>
>   Since the .gitignore is created in the output directory, it is no longer
> necessary to put output/ in the .gitignore file.
>
>
>   All of the above could be put in the commit message, of course, but for me
> Yegor's commit message was sufficiently clear :-)

Were we able to convince you?

Regards,
Yegor

>   Regards,
>   Arnout
>
>
> >
> > Regards,
> > Yann E. MORIN.
> >
> >> Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
> >> ---
> >>   .gitignore | 1 -
> >>   Makefile   | 3 +++
> >>   2 files changed, 3 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..86d4444745 100644
> >> --- a/Makefile
> >> +++ b/Makefile
> >> @@ -63,6 +63,9 @@ ifneq ($(findstring @,$(CANONICAL_O)),)
> >>   $(error The build directory can not contain a '@')
> >>   endif
> >>
> >> +# Create a default .gitignore file that ignores everything
> >> +$(shell echo "*" > "$(CANONICAL_O)/.gitignore")
> >> +
> >>   CANONICAL_CURDIR = $(realpath $(CURDIR))
> >>
> >>   REQ_UMASK = 0022
> >> --
> >> 2.34.1
> >>
> >> _______________________________________________
> >> buildroot mailing list
> >> buildroot@buildroot.org
> >> https://lists.buildroot.org/mailman/listinfo/buildroot
> >
Yann E. MORIN Feb. 12, 2024, 8:07 p.m. UTC | #4
Yegor, All,

On 2024-02-12 10:00 +0100, Yegor Yefremov via buildroot spake thusly:
> On Tue, Feb 6, 2024 at 2:37 PM Arnout Vandecappelle <arnout@mind.be> wrote:
> > On 06/02/2024 14:30, Yann E. MORIN wrote:
> > > On 2024-02-06 14:20 +0100, yegorslists--- via buildroot spake thusly:
> > >> From: Yegor Yefremov <yegorslists@googlemail.com>
> > >> This .gitignore file ignores all files in an output directory and
> > >> hence doesn't change the git status.
> > > What are you trying to achieve with this that does not work currently?
> >   I you do `make O=output-test-mypkg` (which I do quite a lot), that output
> > directory doesn't get ignored by git. We could ignore output* but maybe you name
> > the output directory o-foo or something.
> >
> >   Putting a .gitignore in a generated directory is a very elegant solution for
> > that. It is used by e.g. virtualenv, pytest, and a load of other applications
> > that generate output in a directory.
> >
> >   Since the .gitignore is created in the output directory, it is no longer
> > necessary to put output/ in the .gitignore file.
> >   All of the above could be put in the commit message, of course, but for me
> > Yegor's commit message was sufficiently clear :-)
> Were we able to convince you?

I now understand the purpose. Saying I'm convinced is another stride.

In my case, I have all my output directories outside of the buildroot
tree. Having a .gitignore in there would be totally useless and
spurious, and would get caught by my (superficial) tests that no unknown
files gets created outside the build/ target/ and such dirs for example.

So there are pros and cons either ways...

Maybe just create .gitignore only if $(O) a sub-dir of $(TOPDIR) ?

Regards,
Yann E. MORIN.
Arnout Vandecappelle Feb. 12, 2024, 9:51 p.m. UTC | #5
On 12/02/2024 21:07, Yann E. MORIN wrote:
> Yegor, All,
> 
> On 2024-02-12 10:00 +0100, Yegor Yefremov via buildroot spake thusly:
>> On Tue, Feb 6, 2024 at 2:37 PM Arnout Vandecappelle <arnout@mind.be> wrote:
>>> On 06/02/2024 14:30, Yann E. MORIN wrote:
>>>> On 2024-02-06 14:20 +0100, yegorslists--- via buildroot spake thusly:
>>>>> From: Yegor Yefremov <yegorslists@googlemail.com>
>>>>> This .gitignore file ignores all files in an output directory and
>>>>> hence doesn't change the git status.
>>>> What are you trying to achieve with this that does not work currently?
>>>    I you do `make O=output-test-mypkg` (which I do quite a lot), that output
>>> directory doesn't get ignored by git. We could ignore output* but maybe you name
>>> the output directory o-foo or something.
>>>
>>>    Putting a .gitignore in a generated directory is a very elegant solution for
>>> that. It is used by e.g. virtualenv, pytest, and a load of other applications
>>> that generate output in a directory.
>>>
>>>    Since the .gitignore is created in the output directory, it is no longer
>>> necessary to put output/ in the .gitignore file.
>>>    All of the above could be put in the commit message, of course, but for me
>>> Yegor's commit message was sufficiently clear :-)
>> Were we able to convince you?
> 
> I now understand the purpose. Saying I'm convinced is another stride.
> 
> In my case, I have all my output directories outside of the buildroot
> tree. Having a .gitignore in there would be totally useless and
> spurious, and would get caught by my (superficial) tests that no unknown
> files gets created outside the build/ target/ and such dirs for example.

  That sounds like something you should update regularly, because we regularly 
add new stuff in the output directory.


> So there are pros and cons either ways...
> 
> Maybe just create .gitignore only if $(O) a sub-dir of $(TOPDIR) ?

  That would be quite complicated, while this patch is pretty simple.

  Regards,
  Arnout

> 
> Regards,
> Yann E. MORIN.
>
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..86d4444745 100644
--- a/Makefile
+++ b/Makefile
@@ -63,6 +63,9 @@  ifneq ($(findstring @,$(CANONICAL_O)),)
 $(error The build directory can not contain a '@')
 endif
 
+# Create a default .gitignore file that ignores everything
+$(shell echo "*" > "$(CANONICAL_O)/.gitignore")
+
 CANONICAL_CURDIR = $(realpath $(CURDIR))
 
 REQ_UMASK = 0022