Skip to content

.gitignore not taken into account when multiple search paths are provided #3376

@Erwyn

Description

@Erwyn

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

ripgrep 15.1.0

features:+pcre2
simd(compile):+SSE2,-SSSE3,-AVX2
simd(runtime):+SSE2,+SSSE3,+AVX2

PCRE2 10.45 is available (JIT is available)

How did you install ripgrep?

Nixpkgs stable 25.11

What operating system are you using ripgrep on?

NixOs 25.11

Describe your bug.

.gitignore seems to be not taken into account if mutiple search paths are provided

What are the steps to reproduce the behavior?

  1. mkdir tests src
  2. echo "this" > tests/valid && echo "this" > src/valid && echo "this" > src/invalid
  3. git init . && echo "src/invalid" > .gitignore
  4. rg "this" => no src/invalid
  5. rg "this" src/ => no src/invalid
  6. rg "this" src/ tests/ => src/invalid is found
  7. rg "this" tests/ src/ => funnily, src/invalid is not found

What is the actual behavior?

❯ rg --debug "this" src tests
rg: DEBUG|rg::flags::parse|crates/core/flags/parse.rs:97: no extra arguments found from configuration file
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:954: read CWD from environment: /tmp/reproduce
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1092: number of paths given to search: 2
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1103: is_one_file? false
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1278: found hostname for hyperlink configuration: sunbase
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1288: hyperlink format: ""
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:175: using 12 thread(s)
rg: DEBUG|grep_regex::config|/build/source/crates/regex/src/config.rs:175: assembling HIR from 1 fixed string literals
rg: DEBUG|ignore::gitignore|crates/ignore/src/gitignore.rs:398: opened gitignore file: /tmp/reproduce/.gitignore
rg: DEBUG|globset|crates/globset/src/lib.rs:515: built glob set; 1 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
rg: DEBUG|ignore::gitignore|crates/ignore/src/gitignore.rs:398: opened gitignore file: /tmp/reproduce/.git/info/exclude
src/valid
1:this

src/invalid
1:this

tests/valid
1:this

What is the expected behavior?

In step 6. of reproduction I feel that I should not find src/invalid

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions