Skip to content

Positive --glob cannot override a conflicting file type filter, causing missed files #195

Closed

Description

@wuliangtdi

Summary

Combining a positive glob with a conflicting -t type selection admits no files in tgrep, while ripgrep lets the explicit positive glob override the type filter.

This affects content searches and --files. The files in this reproduction are ordinary, unignored, non-hidden files. This is separate from the documented indexed-mode limitation that positive globs do not reinclude ignored files; the scan path reproduces this difference too.

Reproduce

mkdir repro-glob-type && cd repro-glob-type
mkdir data
printf 'needle\n' > data/a.rs
printf 'needle\n' > data/a.txt

tgrep --no-index -t rust -g '*.txt' -l -- needle data
rg               -t rust -g '*.txt' -l -- needle data

tgrep --no-index --files -t rust -g '*.txt' data
rg               --files -t rust -g '*.txt' data
Case Actual: tgrep 1.2.0 Expected: rg 15.1.0
Content search No stdout, exit 1 data/a.txt, exit 0
--files No stdout, exit 0 data/a.txt, exit 0

The content-search cases reproduce with --no-index, an on-disk index, and tgrep serve --no-watch.

To repeat the indexed cases, run tgrep index data, remove --no-index, and keep the directory path data. For the server cases, start tgrep serve --no-watch data in another terminal and repeat those directory searches. --stats was used in the Windows harness to verify the selected backend, including (via server).

--files was separately verified in scan and local-index modes; it is not counted as a server content-search result.

Environment

  • tgrep 1.2.0, official Windows x86_64 release.
  • Source inspected at release commit 3ba6ee02537281b68ee1366bb40df9f8b7cc54f0.
  • Windows; test harness run with PowerShell 7.
  • ripgrep 15.1.0 (af60c2de9d).
  • Verified on 2026-10-12. The shell examples describe the same fixture bytes and arguments tested on Windows.

Cause

tgrep-cli/src/search.rs:2222 combines the two predicates with type_filter.matches(rel_path) && glob_filter.matches(rel_path). A path rejected by the type filter cannot be admitted by a positive glob.

Possible fix

Resolve explicit glob overrides with the same precedence as ripgrep instead of intersecting every positive glob with type admission. Keep negative globs, normal ignore rules, and the separately documented indexed-corpus restrictions intact.

A regression could assert admission of a.txt for both content search and --files, with ordinary eligible files and the same combination of -t and positive -g.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions