Skip to content

[Finder] Add note about .gitignore rules precedence #16056

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 25, 2021

Conversation

julienfalque
Copy link
Contributor

Closes #16055.

@javiereguiluz
Copy link
Member

javiereguiluz commented Nov 5, 2021

@julienfalque I was reading Git's manual about gitignore and I found the following:

When deciding whether to ignore a path, Git normally checks gitignore
patterns from multiple sources, with the following order of precedence,
from highest to lowest [...]:

(1) [...]
(2) Patterns read from a .gitignore file in the same directory as the path,
    or in any parent directory (up to the top-level of the working 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 .gitignore files in its repository,
    containing patterns for files generated as part of the project build.
(3) ...
(4) ...

So, we say that we ignore .gitignore files in parent dirs to follow Git's behavior ... but it's the opposite, right?

@julienfalque
Copy link
Contributor Author

The current Finder implementation does follow this rule (this is the first sentence added in this PR) with one limitation: instead of starting from the top-level of the Git working tree down to the checked files, it starts from the search directory provided to Finder (this is the note added in this PR). This limitation should be removed with symfony/symfony#43239.

Maybe the wording in this PR is confusing, I'm open to suggestions.

@javiereguiluz javiereguiluz merged commit 3da306e into symfony:5.4 Nov 25, 2021
@julienfalque julienfalque deleted the finder-resursive-gitignore branch November 25, 2021 08:14
@julienfalque
Copy link
Contributor Author

Thanks @javiereguiluz!

@javiereguiluz
Copy link
Member

Thanks Julien for this contribution. I did some minor rewords in 4f475d6 but the essence of your contribution remained. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Finder] Add .gitignore nested negated patterns support
3 participants