Skip to content
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

Meaning of a glob like a/*.c #509

Open
monnier opened this issue Jun 18, 2024 · 1 comment · May be fixed by editorconfig/specification#49
Open

Meaning of a glob like a/*.c #509

monnier opened this issue Jun 18, 2024 · 1 comment · May be fixed by editorconfig/specification#49
Labels

Comments

@monnier
Copy link

monnier commented Jun 18, 2024

Let's say we have a section whose glob looks like *.c in a /foo/.editorconfig. AFAICT this section will apply to any file matching the glob /foo/**/*.c, right?

What about a/*.c? Will it match files of the form /foo/**/a/*.c or only /foo/a/*.c?
Is there a way to have a section that applies only to files of the form /foo/*.c (i.e. to C files in /foo but not in subdirectories)?
The spec says very little about these things.

@monnier monnier added the bug label Jun 18, 2024
@xuhdev
Copy link
Member

xuhdev commented Jun 18, 2024

I agree this is indeed confusing. The spec intends to say that the rules are similar to those used by .gitignore. Therefore, a/*.c doesn't match foo/a/a.c. This is the part of gitignore that we follow:

If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.

We should make this clear and add it to the spec and tests.

xuhdev added a commit to editorconfig/specification that referenced this issue Jun 18, 2024
This is consistent with the rules from `.gitignore`: <https://git-scm.com/docs/gitignore>

> If there is a separator at the beginning or middle (or both) of the
> pattern, then the pattern is relative to the directory level of the
> particular .gitignore file itself. Otherwise the pattern may also match
> at any level below the .gitignore level.

Since we intend to be consistent with `.gitignore`, this part of the
spec has been unclear.

Fix editorconfig/editorconfig#509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants