ripgrep
ripgrep recursively searches directories for a regex pattern while respecting your gitignore
by BurntSushiRust
Commit activity
Last 12 weeks · 17 commits
Community health
3 of 6 standards met
Recent PRs & issues
Opening this issue as suggested by @BurntSushi in #1111. I think it would be helpful if ripgrep can support scanning archive files. Scanning tar files can briefly done via option, but there are downsides: you need to extract all files from the archive and scan again to identify the files you want the line number is unhelpfully large it may be wasting time on scanning files that we don't actually need It is unclear how scanning archive files should work. It should definitely be opt-in just like . We can probably add or for this purpose. I guess ideally archive files should probably be handled like directory rather than single file in that mode. That should lead to some thing like path/to/archive.tar/file1 something matched path/to/archive.tar/file2 something else matched @BurntSushi what do you think?
Pull Request: Introduce Configurable Hidden-File Matching in GlobBuilder Summary This PR introduces two novel configurable options to GlobBuilder: require_literal_leading_dot and recursive_match_hidden_dir. Crucially, their default values are meticulously configured to preserve the existing behavior out of the box, thereby ensuring absolute backward compatibility. Motivation The primary impetus for this enhancement stems from a semantic divergence: globset currently matches components beginning with a dot for patterns like /?/, a behavior that starkly contradicts the established conventions of .gitignore. Furthermore, as meticulously documented in issue #2229, the nushell project is eager to adopt this crate to supersede the legacy glob crate, which necessitates bridging this semantic gap to meet user expectations. Implementation Challenges Overcoming the lack of look-around assertions in the underlying regex engine constitutes the core technical hurdle. Consequently, we are compelled to track the "component-start" state at the token level. It is imperative that the token at the starting position expands into a non-empty form; otherwise, hidden components would still be able to sneak in by starting with a dot. Another pivotal modification involves why MatchStrategy::new must be altered. Specific fast paths—such as the suffix path for /foo and the extension path for /.foo—inadvertently bypass the * semantics. To iron out this flaw, we short-circuit directly to the Regex strategy at the entry point whenever these edge cases come into play. Testing and Impact To guarantee robustness, a total of 20 new test cases have been incorporated. Local verification demonstrates that cargo test -p globset passes all 321 tests, and cargo test --workspace is entirely green. Ultimately, this enhancement is strictly confined to the library API level and leaves the CLI behavior of ripgrep (rg) completely unaffected. AI was used to help implement and test this change. I reviewed every line and can explain the reasoning behind each part.
Please tick this box to confirm you have reviewed the above. [X] I have a different issue. What version of ripgrep are you using? ripgrep 13.0.0 SIMD -AVX (compiled) +SIMD +AVX (runtime) How did you install ripgrep? APT What operating system are you using ripgrep on? Kubuntu 23.10 Describe your bug. This is similar to #2420, and I understand why that's WONTFIX. This is different though. Using a multiline regexp, when the regexp matches strings that come immediately one after another, it bungles the line numbers of all of them. Easier to show you with a reproduction example: What are the steps to reproduce the behavior? Save a file containing: Then run What is the actual behavior? The result is Only the first hit is correct. You can see that the line numbers will be correctly reported if you modify the file to add a newline after each instance of ":end:". What is the expected behavior? Expected the result:
Recent fixes
With the default empty hyperlink format, still resolves each printed path before discovering that no hyperlink will be emitted. On Unix, this unnecessarily calls , including for logical paths such as archive members. Return the existing inactive status before calling when the format is empty. The production change is three lines and leaves non-empty formats on the existing path. The regression test checks that the lazy path cache remains uninitialized and that output bytes are preserved, with and without headings. A Unix control checks that enabled hyperlinks still resolve the path and emit opening/closing sequences. The cache accessor is compiled only for tests. Fixes #3594. Validation on macOS arm64, Rust 1.99.1: Without the three-line fix, the new regression test fails at the cache-initialization assertion; the enabled-hyperlink control passes. : 111 unit tests and 3 doc tests passed. : 104 unit tests and 3 doc tests passed. : 114 unit tests and 323 integration tests passed. and passed. AI assistance: Codex assisted with the implementation, tests, local validation, and this technical summary. No measured speedup or Windows/Linux test run is claimed.
Repository: BurntSushi/ripgrep. Description: ripgrep recursively searches directories for a regex pattern while respecting your gitignore Stars: 69978, Forks: 3520. Primary language: Rust. Languages: Rust (95%), Python (2.4%), Shell (1.9%), Roff (0.7%), Ruby (0%). License: Unlicense. Topics: cli, command-line, command-line-tool, gitignore, grep, recursively-search, regex, ripgrep, rust, search. Latest release: 15.2.0 (4mo ago). Open PRs: 97, open issues: 129. Last activity: 6d ago. Community health: 71%. Top contributors: BurntSushi, okdana, jgarte, balajisivaraman, tiehuis, charliermarsh, ericbn, lyuha, atouchet, igor-raits and others.