Skip to content

[Finder] Add recursive .gitignore files support #43150

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
Sep 27, 2021

Conversation

julienfalque
Copy link
Contributor

@julienfalque julienfalque commented Sep 23, 2021

Q A
Branch? 5.4
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR TODO

This PR extends Finder's .gitignore support to nested files.

Note: as a side effect, a .gitignore file is not required at the top level anymore. Actually, if no .gitignore file is found at all, no errors will be triggered.

@carsonbot
Copy link

Hey!

I think @simPod has recently worked with this code. Maybe they can help review this?

Cheers!

Carsonbot

@julienfalque julienfalque force-pushed the finder-recursive-gitignore branch from c936e40 to 3270237 Compare September 24, 2021 15:40
@julienfalque julienfalque force-pushed the finder-recursive-gitignore branch from de4266f to 5152336 Compare September 26, 2021 08:44
@fabpot
Copy link
Member

fabpot commented Sep 27, 2021

Thank you @julienfalque.

@julienfalque
Copy link
Contributor Author

Thanks @fabpot @nicolas-grekas @keradus!

@julienfalque julienfalque deleted the finder-recursive-gitignore branch September 28, 2021 12:27
@stof
Copy link
Member

stof commented Sep 28, 2021

This seems to look for .gitignore files up to the root of the flesystem, which won't play well with open_basedir restrictions. We should have a way to limit the recursion to parents.

@julienfalque
Copy link
Contributor Author

The look up is supposed to stop at the initial search directory, though no tests prove that. I'll try to add some.

@stof
Copy link
Member

stof commented Sep 28, 2021

@julienfalque is this !== working fine on Windows, or do we have issues of / vs \ as separator ?

@julienfalque
Copy link
Contributor Author

Looks like this was not working fine on Windows (tests seem to cause an infinite loop on AppVeyor). See #43239.

@fabpot fabpot mentioned this pull request Nov 5, 2021
@fabpot fabpot mentioned this pull request Nov 5, 2021
fabpot added a commit that referenced this pull request Apr 1, 2022
…ulienfalque)

This PR was merged into the 6.1 branch.

Discussion
----------

[Finder] Look for gitignore patterns up to git root

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | no
| New feature?  | yes-ish
| Deprecations? | no
| Tickets       | #43150 (comment)
| License       | MIT
| Doc PR        | -

Commits
-------

744392d [Finder] Look for gitignore patterns up to git root
{
$file = $this->current();

$fileRealPath = $file->getRealPath();
Copy link
Contributor

@mvorisek mvorisek Jul 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@julienfalque realpath can be slow and I do not think this is actually correct by git spec at all

Imagine a symlink excluded by a .gitignore. The symlink will not be ignored a it is resolved here.

see https://stackoverflow.com/questions/40460216/how-do-i-make-git-ignore-symlink#40461160

also there should be no is_dir/is_dir, simply traverse the path up

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.

7 participants