Ripgrep: .gitignore? ignored!

Created on 27 May 2020  ·  4Comments  ·  Source: BurntSushi/ripgrep

ripgrep version

❯ rg --version
ripgrep 12.1.0
-SIMD -AVX (compiled)
+SIMD -AVX (runtime)

Means of installation

sudo pacman -S ripgrep

OS

❯ uname -r
5.6.12-1-MANJARO

Bug description

ripgrep searches through files that are listed in .gitignore, possibly related to closed issue 1336

Reproduction

❯ ls -A
bakfile  .gitignore  testfile
❯ cat bakfile
Find me
❯ cat testfile
Find me
❯ cat .gitignore
bakfile
❯ rg 'Find me'
testfile
1:Find me

bakfile     # <<< should not be searched
1:Find me
❯ rg 'Find me' --glob='!bakfile'
testfile
1:Find me
❯ type rg    # check if rg is aliased
rg is /usr/bin/rg
❯ rg --debug 'Find me'
DEBUG|grep_regex::literal|crates/regex/src/literal.rs:58: literal prefixes detected: Literals { lits: [Complete(Find me)], limit_size: 250, limit_class: 10 }
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 1 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|ignore::walk|crates/ignore/src/walk.rs:1730: ignoring ./.gitignore: Ignore(IgnoreMatch(Hidden))
testfile
1:Find me

bakfile
1:Find me
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
DEBUG|globset|crates/globset/src/lib.rs:431: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes

What is the expected behavior?

Respecting the .gitignore file, as per spec.

doc

Most helpful comment

I already figured out to just rename my .gitignore to .ignore. However I wish to encourage to update the documentation (might do a PR on that), because in the corresponding section the claim to respect the .gitignore is literally the first point on the list and I can't find the line where it states that you need to be in a git repo for this to be supported. It tells you how to turn it off, not how to turn it on.

If doing the PR, do I assume correctly that the precedence is .rgignore > .ignore > .gitignore?

All 4 comments

Think you want this

    By default, ripgrep will only respect global gitignore rules,
    .gitignore rules and local exclude rules if ripgrep detects that
    you are searching inside a git repository. This flag allows you to
    relax this restriction such that ripgrep will respect all git
    related ignore rules regardless of whether you're searching in a
    git repository or not.

    This flag can be disabled with --require-git.

(See https://github.com/BurntSushi/ripgrep/commit/d0659282e65dde46e0b5f373d89042b2fe1d4884)

I already figured out to just rename my .gitignore to .ignore. However I wish to encourage to update the documentation (might do a PR on that), because in the corresponding section the claim to respect the .gitignore is literally the first point on the list and I can't find the line where it states that you need to be in a git repo for this to be supported. It tells you how to turn it off, not how to turn it on.

If doing the PR, do I assume correctly that the precedence is .rgignore > .ignore > .gitignore?

I think that's right, assuming that list is highest to lowest priority. And it only applies where there's a conflict (like one says foo and one says !foo); otherwise it just merges them all together

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andschwa picture andschwa  ·  3Comments

crumblingstatue picture crumblingstatue  ·  3Comments

davidtwco picture davidtwco  ·  3Comments

chopfitzroy picture chopfitzroy  ·  3Comments

daxim picture daxim  ·  3Comments