diff mbox series

.gitignore: include common build sub-directories

Message ID 20200413162902.7985-1-alex.bennee@linaro.org
State New
Headers show
Series .gitignore: include common build sub-directories | expand

Commit Message

Alex Bennée April 13, 2020, 4:29 p.m. UTC
As out-of-tree builds become more common (or rather building in a
subdir) we can add a lot of load to "git ls-files" as it hunts down
sub-directories that are irrelevant to the source tree. This is
especially annoying if you have a prompt that attempts to summarise
the current git status on command completion.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

Comments

Eric Blake April 13, 2020, 6:26 p.m. UTC | #1
On 4/13/20 11:29 AM, Alex Bennée wrote:
> As out-of-tree builds become more common (or rather building in a
> subdir) we can add a lot of load to "git ls-files" as it hunts down
> sub-directories that are irrelevant to the source tree. This is
> especially annoying if you have a prompt that attempts to summarise
> the current git status on command completion.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>   .gitignore | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/.gitignore b/.gitignore
> index 0c5af83aa74..7757dc08a08 100644
> --- a/.gitignore
> +++ b/.gitignore
> @@ -141,6 +141,8 @@ cscope.*
>   tags
>   TAGS
>   docker-src.*
> +build
> +builds

Would 'build-*' be worth adding as well?

The idea makes sense to me (as I've already done the same in my 
./git/info/exclude locally),
Reviewed-by: Eric Blake <eblake@redhat.com>
Alex Bennée April 13, 2020, 9:32 p.m. UTC | #2
Eric Blake <eblake@redhat.com> writes:

> On 4/13/20 11:29 AM, Alex Bennée wrote:
>> As out-of-tree builds become more common (or rather building in a
>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>> sub-directories that are irrelevant to the source tree. This is
>> especially annoying if you have a prompt that attempts to summarise
>> the current git status on command completion.
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> ---
>>   .gitignore | 2 ++
>>   1 file changed, 2 insertions(+)
>> diff --git a/.gitignore b/.gitignore
>> index 0c5af83aa74..7757dc08a08 100644
>> --- a/.gitignore
>> +++ b/.gitignore
>> @@ -141,6 +141,8 @@ cscope.*
>>   tags
>>   TAGS
>>   docker-src.*
>> +build
>> +builds
>
> Would 'build-*' be worth adding as well?

Sure - I'll add it to v2.

>
> The idea makes sense to me (as I've already done the same in my
> ./git/info/exclude locally),
> Reviewed-by: Eric Blake <eblake@redhat.com>
Eric Blake April 13, 2020, 9:42 p.m. UTC | #3
On 4/13/20 4:32 PM, Alex Bennée wrote:
> 
> Eric Blake <eblake@redhat.com> writes:
> 
>> On 4/13/20 11:29 AM, Alex Bennée wrote:
>>> As out-of-tree builds become more common (or rather building in a
>>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>>> sub-directories that are irrelevant to the source tree. This is
>>> especially annoying if you have a prompt that attempts to summarise
>>> the current git status on command completion.
>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>    .gitignore | 2 ++
>>>    1 file changed, 2 insertions(+)
>>> diff --git a/.gitignore b/.gitignore
>>> index 0c5af83aa74..7757dc08a08 100644
>>> --- a/.gitignore
>>> +++ b/.gitignore
>>> @@ -141,6 +141,8 @@ cscope.*
>>>    tags
>>>    TAGS
>>>    docker-src.*
>>> +build
>>> +builds
>>
>> Would 'build-*' be worth adding as well?
> 
> Sure - I'll add it to v2.

Or even consolidate it into a single pattern: build* (which would allow 
'build', 'builds', 'build1', 'build23', 'build-fedora', 'build-bug1234', 
...)
Philippe Mathieu-Daudé April 13, 2020, 9:45 p.m. UTC | #4
On 4/13/20 11:42 PM, Eric Blake wrote:
> On 4/13/20 4:32 PM, Alex Bennée wrote:
>>
>> Eric Blake <eblake@redhat.com> writes:
>>
>>> On 4/13/20 11:29 AM, Alex Bennée wrote:
>>>> As out-of-tree builds become more common (or rather building in a
>>>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>>>> sub-directories that are irrelevant to the source tree. This is
>>>> especially annoying if you have a prompt that attempts to summarise
>>>> the current git status on command completion.
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> ---
>>>>    .gitignore | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>> diff --git a/.gitignore b/.gitignore
>>>> index 0c5af83aa74..7757dc08a08 100644
>>>> --- a/.gitignore
>>>> +++ b/.gitignore
>>>> @@ -141,6 +141,8 @@ cscope.*
>>>>    tags
>>>>    TAGS
>>>>    docker-src.*
>>>> +build
>>>> +builds
>>>
>>> Would 'build-*' be worth adding as well?
>>
>> Sure - I'll add it to v2.
> 
> Or even consolidate it into a single pattern: build* (which would allow
> 'build', 'builds', 'build1', 'build23', 'build-fedora', 'build-bug1234',
> ...)

Using 'build*':
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Markus Armbruster April 14, 2020, 8 a.m. UTC | #5
Eric Blake <eblake@redhat.com> writes:

> On 4/13/20 4:32 PM, Alex Bennée wrote:
>>
>> Eric Blake <eblake@redhat.com> writes:
>>
>>> On 4/13/20 11:29 AM, Alex Bennée wrote:
>>>> As out-of-tree builds become more common (or rather building in a
>>>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>>>> sub-directories that are irrelevant to the source tree. This is
>>>> especially annoying if you have a prompt that attempts to summarise
>>>> the current git status on command completion.
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> ---
>>>>    .gitignore | 2 ++
>>>>    1 file changed, 2 insertions(+)
>>>> diff --git a/.gitignore b/.gitignore
>>>> index 0c5af83aa74..7757dc08a08 100644
>>>> --- a/.gitignore
>>>> +++ b/.gitignore
>>>> @@ -141,6 +141,8 @@ cscope.*
>>>>    tags
>>>>    TAGS
>>>>    docker-src.*
>>>> +build
>>>> +builds
>>>
>>> Would 'build-*' be worth adding as well?
>>
>> Sure - I'll add it to v2.
>
> Or even consolidate it into a single pattern: build* (which would
> allow 'build', 'builds', 'build1', 'build23', 'build-fedora',
> 'build-bug1234', ...)

The looser the pattern, the higher the risk of unwanted matches.

Would be less of an issue if we had a cleaner source root directory.
Alex Bennée April 14, 2020, 8:47 a.m. UTC | #6
Markus Armbruster <armbru@redhat.com> writes:

> Eric Blake <eblake@redhat.com> writes:
>
>> On 4/13/20 4:32 PM, Alex Bennée wrote:
>>>
>>> Eric Blake <eblake@redhat.com> writes:
>>>
>>>> On 4/13/20 11:29 AM, Alex Bennée wrote:
>>>>> As out-of-tree builds become more common (or rather building in a
>>>>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>>>>> sub-directories that are irrelevant to the source tree. This is
>>>>> especially annoying if you have a prompt that attempts to summarise
>>>>> the current git status on command completion.
>>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>>> ---
>>>>>    .gitignore | 2 ++
>>>>>    1 file changed, 2 insertions(+)
>>>>> diff --git a/.gitignore b/.gitignore
>>>>> index 0c5af83aa74..7757dc08a08 100644
>>>>> --- a/.gitignore
>>>>> +++ b/.gitignore
>>>>> @@ -141,6 +141,8 @@ cscope.*
>>>>>    tags
>>>>>    TAGS
>>>>>    docker-src.*
>>>>> +build
>>>>> +builds
>>>>
>>>> Would 'build-*' be worth adding as well?
>>>
>>> Sure - I'll add it to v2.
>>
>> Or even consolidate it into a single pattern: build* (which would
>> allow 'build', 'builds', 'build1', 'build23', 'build-fedora',
>> 'build-bug1234', ...)
>
> The looser the pattern, the higher the risk of unwanted matches.
>
> Would be less of an issue if we had a cleaner source root directory.

True but as of now we don't have anything matching bu* so I think build*
is fairly safe. I have ran into problems with over lax .gitignore
stanzas before but I don't think it's taken too long to figure out what
was going on. It's not like having a build subdir isn't a common
"out-of-tree" build idiom.
Philippe Mathieu-Daudé April 14, 2020, 9:53 a.m. UTC | #7
On 4/14/20 10:47 AM, Alex Bennée wrote:
> 
> Markus Armbruster <armbru@redhat.com> writes:
> 
>> Eric Blake <eblake@redhat.com> writes:
>>
>>> On 4/13/20 4:32 PM, Alex Bennée wrote:
>>>>
>>>> Eric Blake <eblake@redhat.com> writes:
>>>>
>>>>> On 4/13/20 11:29 AM, Alex Bennée wrote:
>>>>>> As out-of-tree builds become more common (or rather building in a
>>>>>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>>>>>> sub-directories that are irrelevant to the source tree. This is
>>>>>> especially annoying if you have a prompt that attempts to summarise
>>>>>> the current git status on command completion.
>>>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>>>> ---
>>>>>>     .gitignore | 2 ++
>>>>>>     1 file changed, 2 insertions(+)
>>>>>> diff --git a/.gitignore b/.gitignore
>>>>>> index 0c5af83aa74..7757dc08a08 100644
>>>>>> --- a/.gitignore
>>>>>> +++ b/.gitignore
>>>>>> @@ -141,6 +141,8 @@ cscope.*
>>>>>>     tags
>>>>>>     TAGS
>>>>>>     docker-src.*
>>>>>> +build
>>>>>> +builds
>>>>>
>>>>> Would 'build-*' be worth adding as well?
>>>>
>>>> Sure - I'll add it to v2.
>>>
>>> Or even consolidate it into a single pattern: build* (which would
>>> allow 'build', 'builds', 'build1', 'build23', 'build-fedora',
>>> 'build-bug1234', ...)
>>
>> The looser the pattern, the higher the risk of unwanted matches.
>>
>> Would be less of an issue if we had a cleaner source root directory.
> 
> True but as of now we don't have anything matching bu* so I think build*
> is fairly safe. I have ran into problems with over lax .gitignore
> stanzas before but I don't think it's taken too long to figure out what
> was going on. It's not like having a build subdir isn't a common
> "out-of-tree" build idiom.

We can restrict to directories using "build*/":

GITIGNORE(5)

·   If the pattern ends with a slash, it is removed for the
     purpose of the following description, but it would only
     find a match with a directory. In other words, foo/ will
     match a directory foo and paths underneath it, but will
     not match a regular file or a symbolic link foo (this is
     consistent with the way how pathspec works in general in
     Git).
Richard Henderson April 14, 2020, 3:06 p.m. UTC | #8
On 4/13/20 9:29 AM, Alex Bennée wrote:
> As out-of-tree builds become more common (or rather building in a
> subdir) we can add a lot of load to "git ls-files" as it hunts down
> sub-directories that are irrelevant to the source tree. This is
> especially annoying if you have a prompt that attempts to summarise
> the current git status on command completion.

Not a fan.  Why do we encourage putting the build directory in tree anyway?
IMO any out-of-tree build really should be OUT of tree.

My build directories are always siblings of the source directory in the parent
directory.


r~
Alex Bennée April 14, 2020, 4:31 p.m. UTC | #9
Richard Henderson <richard.henderson@linaro.org> writes:

> On 4/13/20 9:29 AM, Alex Bennée wrote:
>> As out-of-tree builds become more common (or rather building in a
>> subdir) we can add a lot of load to "git ls-files" as it hunts down
>> sub-directories that are irrelevant to the source tree. This is
>> especially annoying if you have a prompt that attempts to summarise
>> the current git status on command completion.
>
> Not a fan.  Why do we encourage putting the build directory in tree anyway?
> IMO any out-of-tree build really should be OUT of tree.
>
> My build directories are always siblings of the source directory in the parent
> directory.


It's not exactly an un-common pattern - especially if you have a lot of
build variants. Keeping them under builds makes it easier to blow the
whole lot away rather than having a messy parent directory which you
have to clean manually.

Personally it also works better with my tooling which can slurp up all
the build directories and present me with a menu of make commands to
build from. That's not a good argument for accepting the patch though.

>
>
> r~
Richard Henderson April 14, 2020, 4:39 p.m. UTC | #10
On 4/14/20 9:31 AM, Alex Bennée wrote:
> Richard Henderson <richard.henderson@linaro.org> writes:
>> My build directories are always siblings of the source directory in the parent
>> directory.
> 
> 
> It's not exactly an un-common pattern - especially if you have a lot of
> build variants. Keeping them under builds makes it easier to blow the
> whole lot away rather than having a messy parent directory which you
> have to clean manually.

"Manual" is a bit of an overstatement.  In the end there's no difference at
all: it's rm -rf build* no matter the $PWD where you perform it.

As for "messy", you're the one that put stuff that doesn't belong into the
source directory.  Mine is nice and clean.  ;-)

> Personally it also works better with my tooling which can slurp up all
> the build directories and present me with a menu of make commands to
> build from. That's not a good argument for accepting the patch though.

Hah.


r~
diff mbox series

Patch

diff --git a/.gitignore b/.gitignore
index 0c5af83aa74..7757dc08a08 100644
--- a/.gitignore
+++ b/.gitignore
@@ -141,6 +141,8 @@  cscope.*
 tags
 TAGS
 docker-src.*
+build
+builds
 *~
 *.ast_raw
 *.depend_raw