Skip to contentSkip to conversation

.gitignore: include common build sub-directories

PATCH In review Alex Bennée 6 participants 11 messages Apr 13, 2020 – Apr 14, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 .gitignore: include common build sub-directories

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.

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)
.gitignore +2 -0
index 0c5af83aa74..7757dc08a08 100644
@@ -141,6 +141,8 @@ cscope.*
 tags
 TAGS
 docker-src.*
+build
+builds
 *~
 *.ast_raw
 *.depend_raw
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Alex Bennée

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.

---
  .gitignore | 2 ++
  1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644

.gitignore cscope.* · line 145

Quoted 5 lines
.gitignore +2 -0
@@ -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),

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 14 lines · Eric Blake
Quoted 13 lines · Alex Bennée

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.

---
  .gitignore | 2 ++
  1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644
Quoted 8 lines

.gitignore cscope.* · line 145

Quoted 6 lines
.gitignore +2 -0
@@ -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.

Quoted 4 lines

The idea makes sense to me (as I've already done the same in my ./git/info/exclude locally),

Signature · 1 line
Alex Bennée
#3 lore raw
Quoted 26 lines · Alex Bennée
Quoted 14 lines · Eric Blake
Quoted 13 lines · Alex Bennée

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.

---
   .gitignore | 2 ++
   1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644
Quoted 8 lines

.gitignore cscope.* · line 145

Quoted 6 lines
.gitignore +2 -0
@@ -141,6 +141,8 @@ cscope.*
   tags
   TAGS
   docker-src.*
+build
+builds

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

Quoted 1 line

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', ...)

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#4 lore raw
Quoted 27 lines · Eric Blake
Quoted 26 lines · Alex Bennée
Quoted 22 lines · Eric Blake
Quoted 17 lines · Alex Bennée

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.

---
   .gitignore | 2 ++

   1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644
@@ -141,6 +141,8 @@ cscope.*

   tags
   TAGS
   docker-src.*

.gitignore cscope.* · line 145

Quoted 2 lines
.gitignore +2 -0
+build
+builds

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

Quoted 5 lines
Quoted 1 line

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*':

#5 lore raw
In reply to Eric Blake
Quoted 27 lines · Eric Blake
Quoted 26 lines · Alex Bennée
Quoted 22 lines · Eric Blake
Quoted 14 lines · Alex Bennée

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.

---
   .gitignore | 2 ++
   1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644

.gitignore cscope.* · line 145

Quoted 5 lines
.gitignore +2 -0
@@ -141,6 +141,8 @@ cscope.*
   tags
   TAGS
   docker-src.*
+build
+builds

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

Quoted 5 lines
Quoted 1 line

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.

#6 lore raw
Quoted 31 lines · Markus Armbruster
Quoted 29 lines · Eric Blake
Quoted 27 lines · Alex Bennée
Quoted 14 lines · Eric Blake
Quoted 13 lines · Alex Bennée

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.

---
   .gitignore | 2 ++
   1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644
Quoted 8 lines

.gitignore cscope.* · line 145

Quoted 6 lines
.gitignore +2 -0
@@ -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.

Quoted 7 lines
Quoted 3 lines

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.

Signature · 1 line
Alex Bennée
#7 lore raw
Quoted 40 lines · Alex Bennée
Quoted 37 lines · Markus Armbruster
Quoted 27 lines · Eric Blake
Quoted 26 lines · Alex Bennée
Quoted 22 lines · Eric Blake
Quoted 14 lines · Alex Bennée

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.

---
    .gitignore | 2 ++
    1 file changed, 2 insertions(+)
.gitignore +0 -0
index 0c5af83aa74..7757dc08a08 100644

.gitignore cscope.* · line 145

Quoted 5 lines
.gitignore +2 -0
@@ -141,6 +141,8 @@ cscope.*
    tags
    TAGS
    docker-src.*
+build
+builds

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

Quoted 5 lines
Quoted 1 line

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.

Quoted 7 lines
Quoted 1 line

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).

#8 lore raw
In reply to Alex Bennée
Quoted 5 lines · Alex Bennée

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~

#9 lore raw
Quoted 7 lines · Richard Henderson
Quoted 5 lines · Alex Bennée

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.

Quoted 5 lines

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.

Quoted 3 lines

r~

Signature · 1 line
Alex Bennée
#10 lore raw
Quoted 9 lines · Alex Bennée
Quoted 2 lines · Richard Henderson

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. ;-)

Quoted 3 lines

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~