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

--hidden + .ignore showing ignored files inside hidden directories #807

Closed
cpixl opened this issue Feb 14, 2018 · 3 comments
Closed

--hidden + .ignore showing ignored files inside hidden directories #807

cpixl opened this issue Feb 14, 2018 · 3 comments
Labels
bug A bug.

Comments

@cpixl
Copy link

cpixl commented Feb 14, 2018

What version of ripgrep are you using?

ripgrep 0.8.0
-SIMD -AVX

What operating system are you using ripgrep on?

Arch Linux

Describe your question, feature request, or bug.

The --hidden and .ignore file combination is not working well for ignored files inside hidden directories e.g. a .a/b/c file shouldn't appear if .ignore contains .a/b.

If this is a bug, what are the steps to reproduce the behavior?

mkdir -p .a/b .a/c
touch .a/b/file .a/c/file
echo .a/b > .ignore
ln -rsf .ignore .gitignore
rg --debug --hidden --files .

If this is a bug, what is the actual behavior?

This is the current output:

DEBUG/rg::config/src/config.rs:42: /home/user/.config/ripgrep/ripgreprc: arguments loaded from config file: ["--smart-case", "--follow"]
DEBUG/rg::args/src/args.rs:143: final argv: ["rg", "--smart-case", "--follow", "--debug", "--hidden", "--files", "."]
DEBUG/grep::search/grep/src/search.rs:195: regex ast:
Repeat {
    e: Literal {
        chars: [
            'z'
        ],
        casei: true
    },
    r: Range {
        min: 0,
        max: Some(
            0
        )
    },
    greedy: true
}
DEBUG/globset/globset/src/lib.rs:396: glob converted to regex: Glob { glob: ".local/share/nvim/{bundle,undo,swap}", re: "(?-u)^\\.local/share/nvim/(swap|undo|bundle)$", opts: GlobOptions { case_insensitive: false, literal_separator: true }, tokens: Tokens([Literal('.'), Literal('l'), Literal('o'), Literal('c'), Literal('a'), Literal('l'), Literal('/'), Literal('s'), Literal('h'), Literal('a'), Literal('r'), Literal('e'), Literal('/'), Literal('n'), Literal('v'), Literal('i'), Literal('m'), Literal('/'), Alternates([Tokens([Literal('s'), Literal('w'), Literal('a'), Literal('p')]), Tokens([Literal('u'), Literal('n'), Literal('d'), Literal('o')]), Tokens([Literal('b'), Literal('u'), Literal('n'), Literal('d'), Literal('l'), Literal('e')])])]) }
DEBUG/globset/globset/src/lib.rs:401: built glob set; 4 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 1 regexes
DEBUG/globset/globset/src/lib.rs:401: built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG/globset/globset/src/lib.rs:401: built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
.ignore
.gitignore
.a/c/file
.a/b/file

If this is a bug, what is the expected behavior?

The same files shown by git status (after a git init && git add .):

On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

	new file:   .a/c/file
	new file:   .gitignore
	new file:   .ignore

As you can see, the .a/b/file was ommited by Git, but not by ripgrep.

@okdana
Copy link
Contributor

okdana commented Feb 14, 2018

FYI, the problem doesn't occur if you do rg --files --hidden or rg --files --hidden $PWD or even rg --files --hidden ./ — you explicitly need to use . for the path

@cpixl
Copy link
Author

cpixl commented Feb 14, 2018

fd is showing a similar behavior with fd --hidden --type file, which makes me believe it may be related to ignore.

@BurntSushi BurntSushi added the bug A bug. label Feb 14, 2018
@BurntSushi
Copy link
Owner

@okdana's observation was spot-on and led me to exactly the place where this needed to be fixed. Thanks @dan-santana for the awesome bug report!

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

No branches or pull requests

3 participants