diff mbox series

docs: .gitignore in parents is current repo only

Message ID 20210702222044.72767-1-andrew@furrypaws.ca (mailing list archive)
State New, archived
Headers show
Series docs: .gitignore in parents is current repo only | expand

Commit Message

Andrew Berry July 2, 2021, 10:20 p.m. UTC
The current documentation reads as if .gitignore files will be parsed in
every parent directory, and not until they reach a repository boundary.
This clarifies the current behaviour.

Signed-off-by: Andrew Berry <andrew@furrypaws.ca>
---
 Documentation/gitignore.txt | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Junio C Hamano July 3, 2021, 12:06 a.m. UTC | #1
Andrew Berry <andrew@furrypaws.ca> writes:

> The current documentation reads as if .gitignore files will be parsed in
> every parent directory, and not until they reach a repository boundary.

Hmph.  While it is not adding an incorrect information to the
documentation per-se, I am not sure if this is necessary to begin
with.  I would have thought that "up to the toplevel of the work
tree" would be sufficiently clear where the upward traversal of the
directories ends, i.e. at the repository boundary.

>   * Patterns read from a `.gitignore` file in the same directory
> -   as the path, or in any parent directory, with patterns in the
> -   higher level files (up to the toplevel of the work tree) being overridden
> -   by those in lower level files down to the directory containing the file.
> -   These patterns match relative to the location of the
> +   as the path, or in any parent directory in the same repository, with
> +   patterns in the higher level files (up to the toplevel of the work tree)
> +   being overridden by those in lower level files down to the directory
> +   containing the file. These patterns match relative to the location of the
>     `.gitignore` file.  A project normally includes such
>     `.gitignore` files in its repository, containing patterns for
>     files generated as part of the project build.
Bagas Sanjaya July 3, 2021, 12:21 a.m. UTC | #2
On 03/07/21 05.20, Andrew Berry wrote:
>    * Patterns read from a `.gitignore` file in the same directory
> -   as the path, or in any parent directory, with patterns in the
> -   higher level files (up to the toplevel of the work tree) being overridden
> -   by those in lower level files down to the directory containing the file.
> -   These patterns match relative to the location of the
> +   as the path, or in any parent directory in the same repository, with
> +   patterns in the higher level files (up to the toplevel of the work tree)
> +   being overridden by those in lower level files down to the directory
> +   containing the file. These patterns match relative to the location of the

So for example I have `something/foo` in ../.gitignore, but .gitignore 
(in current directory `something`) has `foo`. Is .gitignore from current 
directory or ../.gitignore takes effect?

Also s/toplevel/top level/
Andrew Berry July 5, 2021, 5:30 p.m. UTC | #3
On 2 Jul 2021, at 20:06, Junio C Hamano wrote:

> I would have thought that "up to the toplevel of the work
> tree" would be sufficiently clear where the upward traversal of the
> directories ends, i.e. at the repository boundary.

Seems reasonable. What if we move that note to come after "any parent 
directory"?

On 2 Jul 2021, at 20:21, Bagas Sanjaya wrote:

> So for example I have `something/foo` in ../.gitignore, but .gitignore 
> (in current directory `something`) has `foo`. Is .gitignore from 
> current directory or ../.gitignore takes effect?

In this case, both rules resolve to the same path, so I don't think it 
matters? But in practice I'd expect it to be `something/.gitignore`, 
since you can negate the pattern from the parent ignore file.

> Also s/toplevel/top level/

That showed up in the diff due to word wrapping. If no other changes are 
accepted, I'll file a followup after to get this fixed on it's own.
Junio C Hamano July 5, 2021, 7:59 p.m. UTC | #4
"Andrew Berry" <andrew@furrypaws.ca> writes:

> On 2 Jul 2021, at 20:06, Junio C Hamano wrote:
>
>> I would have thought that "up to the toplevel of the work
>> tree" would be sufficiently clear where the upward traversal of the
>> directories ends, i.e. at the repository boundary.
>
> Seems reasonable. What if we move that note to come after "any parent
> directory"?

Meaning something like the following?

I do agree that it makes it a lot clearer.

 Documentation/gitignore.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git c/Documentation/gitignore.txt w/Documentation/gitignore.txt
index 53e7d5c914..58c2e41bbe 100644
--- c/Documentation/gitignore.txt
+++ w/Documentation/gitignore.txt
@@ -27,8 +27,8 @@ precedence, the last matching pattern decides the outcome):
    them.
 
  * Patterns read from a `.gitignore` file in the same directory
-   as the path, or in any parent directory, with patterns in the
-   higher level files (up to the toplevel of the work tree) being overridden
+   as the path, or in any parent directory (up to the toplevel of
+   the work tree), with patterns in the higher level files being overridden
    by those in lower level files down to the directory containing the file.
    These patterns match relative to the location of the
    `.gitignore` file.  A project normally includes such
Andrew Berry July 5, 2021, 11:50 p.m. UTC | #5
On 5 Jul 2021, at 15:59, Junio C Hamano wrote:

> "Andrew Berry" <andrew@furrypaws.ca> writes:
>
> Meaning something like the following?
>
> I do agree that it makes it a lot clearer.
>
>  Documentation/gitignore.txt | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git c/Documentation/gitignore.txt w/Documentation/gitignore.txt
> index 53e7d5c914..58c2e41bbe 100644
> --- c/Documentation/gitignore.txt
> +++ w/Documentation/gitignore.txt
> @@ -27,8 +27,8 @@ precedence, the last matching pattern decides the 
> outcome):
>     them.
>
>   * Patterns read from a `.gitignore` file in the same directory
> -   as the path, or in any parent directory, with patterns in the
> -   higher level files (up to the toplevel of the work tree) being 
> overridden
> +   as the path, or in any parent directory (up to the toplevel of
> +   the work tree), with patterns in the higher level files being 
> overridden
>     by those in lower level files down to the directory containing the 
> file.
>     These patterns match relative to the location of the
>     `.gitignore` file.  A project normally includes such

Yes, that's good. My only suggestion would mirror the earlier one, to 
split toplevel to "top-level" or "top level".
Junio C Hamano July 6, 2021, 4:18 p.m. UTC | #6
"Andrew Berry" <andrew@furrypaws.ca> writes:

> split toplevel to "top-level" or "top level".

Ah, that's even better.
diff mbox series

Patch

diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 53e7d5c914..534cda5747 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -27,10 +27,10 @@  precedence, the last matching pattern decides the outcome):
    them.
 
  * Patterns read from a `.gitignore` file in the same directory
-   as the path, or in any parent directory, with patterns in the
-   higher level files (up to the toplevel of the work tree) being overridden
-   by those in lower level files down to the directory containing the file.
-   These patterns match relative to the location of the
+   as the path, or in any parent directory in the same repository, with
+   patterns in the higher level files (up to the toplevel of the work tree)
+   being overridden by those in lower level files down to the directory
+   containing the file. These patterns match relative to the location of the
    `.gitignore` file.  A project normally includes such
    `.gitignore` files in its repository, containing patterns for
    files generated as part of the project build.