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

ripgrep glob is not match the gitignore #1001

Closed
jacky1193610322 opened this issue Aug 4, 2018 · 1 comment
Closed

ripgrep glob is not match the gitignore #1001

jacky1193610322 opened this issue Aug 4, 2018 · 1 comment
Labels
invalid An issue that is not actually a bug or a feature that already exists.

Comments

@jacky1193610322
Copy link

jacky1193610322 commented Aug 4, 2018

What version of ripgrep are you using?

ripgrep 0.8.1
-SIMD -AVX

How did you install ripgrep?

brew install ripgrep

What operating system are you using ripgrep on?

macos 10.14

Describe your question, feature request, or bug.

➜  temp tree test1
test1
└── test2
    └── a.txt

1 directory, 1 file
➜  temp rg --files -g "test2/" --debug
DEBUG/globset/globset/src/lib.rs:401: built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG/grep::search/grep/src/search.rs:195: regex ast:
Repeat {
    e: Literal {
        chars: [
            'z'
        ],
        casei: false
    },
    r: Range {
        min: 0,
        max: Some(
            0
        )
    },
    greedy: true
}
DEBUG/ignore::walk/ignore/src/walk.rs:1428: ignoring ./jsonschema.json: Ignore(IgnoreMatch(Override(Glob(UnmatchedIgnore))))
DEBUG/ignore::walk/ignore/src/walk.rs:1428: ignoring ./testarg.py: Ignore(IgnoreMatch(Override(Glob(UnmatchedIgnore))))
DEBUG/ignore::walk/ignore/src/walk.rs:1428: ignoring ./dto/IamJsonschemaDTO.java: Ignore(IgnoreMatch(Override(Glob(UnmatchedIgnore))))
DEBUG/ignore::walk/ignore/src/walk.rs:1431: whitelisting ./test1/test2: Whitelist(IgnoreMatch(Override(Glob(Matched(Glob { from: None, original: "test2/", actual: "**/test2", is_whitelist: false, is_only_dir: true })))))
DEBUG/ignore::walk/ignore/src/walk.rs:1428: ignoring ./test1/test2/a.txt: Ignore(IgnoreMatch(Override(Glob(UnmatchedIgnore))))

but in the man gitignore
image

so why rg not support the rule

I use rg to search test2 directory and paths underneath it,but it doesn't work.

and in the gitignore, if I add test2, which also match test1/test2/a and test2/a,
but rg "test" -g "test2" only match test2 in the current directory(./test2), not match ./test1/test2
I see the debug output rg "test" -g "test2" which mean rg "test" -g "**/test2"
it match the test2 directory, but it doesn't match the subpath of test2, which is also written in the globset,
but rg document write Globbing rules match .gitignore globs, but it's actually not.
image

@BurntSushi
Copy link
Owner

As far as I can tell, this is behaving as expected. -g test2/ causes any directory named test2 to match, but nothing else. rg -g 'test2/**' should do what you want.

@BurntSushi BurntSushi added the invalid An issue that is not actually a bug or a feature that already exists. label Jan 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid An issue that is not actually a bug or a feature that already exists.
Projects
None yet
Development

No branches or pull requests

2 participants