1
0
mirror of https://github.com/BurntSushi/ripgrep.git synced 2025-08-04 21:52:54 +02:00
Commit Graph

152 Commits

Author SHA1 Message Date
2d763a9a1b ignore/types: add *.svelte.ts to Svelte file type glob
I was somewhat unsure about adding this, since `.svelte.ts` seems
primarily like a TypeScript file and it could be surprising to show up
in a search for Svelte files. In particular, ripgrep doesn't know how to
only search the Svelte stuff inside of a `.svelte.ts` file, so you could
end up with lots of false positives.

However, I was swayed[1] by the argument that the extension does
actually include `svelte` in it, so maybe this is fine. Please open an
issue if this change ends up being too annoying for most users.

Closes #2874, Closes #2909

[1]: https://github.com/BurntSushi/ripgrep/issues/2874#issuecomment-3126892931
2025-07-28 07:58:09 -04:00
0434b5034d ignore/types: add *.rake extension to list of Ruby file types
This PR adds the .rake extension to the Ruby type. It's a pretty common
file extension in Rails apps—in my experience, the Rakefile is often
pretty empty and only sets some stuff up while most of the code lives
in various .rake files.

See: https://ruby.github.io/rake/doc/rakefile_rdoc.html#label-Multiple+Rake+Files

Closes #2921
2025-07-26 11:55:30 -04:00
b004eda8c8 ignore/types: add typst
Closes #2914
2025-07-26 11:54:01 -04:00
0904f55d3e ignore/types: include msbuild solution filters
Closes #2871
2025-07-26 10:50:59 -04:00
d9744f3b03 ignore: improve multithreading heuristic
This copies the one found in ripgrep.

See also:
71d71d2d98/crates/core/flags/hiargs.rs (L172)

Closes #2854, Closes #2856
2025-07-26 10:42:29 -04:00
a6275648b3 ignore: don't process command line arguments in reverse order
When searching in parallel with many more arguments than threads, the
first arguments are searched last -- unlike in the -j1 case.

This is unexpected for users who know about the parallel nature of rg
and think they can give the scheduler a hint by positioning larger
input files (L1, L2, ..) before smaller ones (█, ██). Instead, this can
result in sub-optimal thread usage and thus longer runtime (simplified
example with 2 threads):

 T1:  █ ██ █ █ █ █ ██ █ █ █ █ █ ██ ╠═════════════L1════════════╣
 T2:  █ █ ██ █ █ ██ █ █ █ ██ █ █ ╠═════L2════╣

                                       ┏━━━━┳━━━━┳━━━━┳━━━━┓
This is caused by assigning work to    ┃ T1 ┃ T2 ┃ T3 ┃ T4 ┃
 per-thread stacks in a round-robin    ┡━━━━╇━━━━╇━━━━╇━━━━┩
              manner, starting here  → │ L1 │ L2 │ L3 │ L4 │ ↵
                                       ├────├────┼────┼────┤
                                       │ s5 │ s6 │ s7 │ s8 │ ↵
                                       ├────┼────┼────┼────┤
                                       ╷ .. ╷ .. ╷ .. ╷ .. ╷
                                       ├────┼────┼────┼────┤
                                       │ st │ su │ sv │ sw │ ↵
                                       ├────┼────┼────┼────┘
                                       │ sx │ sy │ sz │
                                       └────┴────┴────┘
   and then processing them bottom-up:   ↥    ↥    ↥    ↥

                                       ╷ .. ╷ .. ╷ .. ╷ .. ╷
This patch reverses the input order    ├────┼────┼────┼────┤
so the two reversals cancel each other │ s7 │ s6 │ s5 │ L4 │ ↵
out. Now at least the first N          ├────┼────┼────┼────┘
arguments, N=number-of-threads, are    │ L3 │ L2 │ L1 │
processed before any others (then      └────┴────┴────┘
work-stealing may happen):

 T1:  ╠═════════════L1════════════╣ █ ██ █ █ █ █ █ █ ██
 T2:  ╠═════L2════╣ █ █ ██ █ █ ██ █ █ █ ██ █ █ ██ █ █ █

(With some more shuffling T1 could always be assigned L1 etc., but
that would mostly be for optics).

Closes #2849
2025-07-26 10:42:29 -04:00
7fc48961ed ignore/types: add Makefile.*
The *BSD build systems make use of "Makefile.inc" a lot. Make the
"make" type recognize this file by default. And more generally,
`Makefile.*` seems to be a convention, so just generalize it.

Closes #2846
2025-07-26 10:42:28 -04:00
bd8a7ae793 ignore: support .jj as well as .git
This makes it so the presence of `.jj` will cause ripgrep to treat it
as a VCS directory, just as if `.git` were present. This is useful for
ripgrep's default behavior when working with jj repositories that don't
have a `.git` but do have `.gitignore`. Namely, ripgrep requires the
presence of a VCS repository in order to respect `.gitignore`.

We don't handle clone-specific exclude rules for jj repositories without
`.git` though. It seems it isn't 100% set yet where we can find
those[1].

Closes #2842

[1]: https://github.com/BurntSushi/ripgrep/pull/2842#discussion_r2020076722
2025-07-26 10:42:28 -04:00
ca88b2fd95 ignore/gitignore: skip BOM at start of ignore file
This matches Git's behavior.

Fixes #2177, Closes #2782
2025-07-26 10:42:28 -04:00
fe07bd7669 ignore/types: detect WORKSPACE.bzlmod for bazel file type
This file came alongside MODULE.bazel and I should have added it here
previously.

Closes #2726
2025-07-26 10:42:28 -04:00
c2f1653ddd ignore: fix filtering searching subdir or .ignore in parent dir
The previous code deleted too many parts of the path when constructing
the absolute path, resulting in a shortened final path. This patch
creates the correct absolute path by only removing the necessary parts.

Fixes #829, Fixes #2731, Fixes #2747, Fixes #2778, Fixes #2836, Fixes #2933
Closes #2933
2025-07-26 10:42:27 -04:00
85a86eba2b impl: switch most atomic ops to Relaxed ordering
These all seem pretty straight-forward. Compared with #2706, I dropped
the changes to the atomic orderings used in `ignore` because I haven't
had time to think through that carefully. But the ops in this PR seem
fine.

Closes #2706
2025-07-26 10:42:27 -04:00
6dfaec03e8 deps: bump crossbeam-channel from 0.5.13 to 0.5.15
Bumps [crossbeam-channel](https://github.com/crossbeam-rs/crossbeam) from 0.5.13 to 0.5.15.
- [Release notes](https://github.com/crossbeam-rs/crossbeam/releases)
- [Changelog](https://github.com/crossbeam-rs/crossbeam/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crossbeam-rs/crossbeam/compare/crossbeam-channel-0.5.13...crossbeam-channel-0.5.15)

---
updated-dependencies:
- dependency-name: crossbeam-channel
  dependency-version: 0.5.15
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-04-10 10:55:32 -04:00
5fbc4fee64 ignore/types: fix Seed7 file extension
PR #3023
2025-04-07 10:53:32 -04:00
004370bd16 ignore/types: add support for Seed7 files
For more info on the Seed7 programming Language see:

- on Wikipedia: https://en.wikipedia.org/wiki/Seed7
- Seed7 home:   https://seed7.sourceforge.net/
- Seed7 repo:   https://github.com/ThomasMertes/seed7

PR #3022
2025-04-07 08:51:22 -04:00
ac02f54c89 ignore-0.4.23 2024-09-08 22:06:03 -04:00
24b337b940 deps: bump globset to 0.4.15 2024-09-08 22:05:45 -04:00
0a0893a765 ignore: add debug log message when opening gitignore file
I'm not sure why it took me this long to add this debug message, but
it's quite useful in determining where ignore rules are coming from.
2024-05-27 14:53:19 -04:00
2acf25c689 ignore/types: add WGSL to the default file types
[WGSL][1] is a shading language for WebGPU. As defined in [Appendix
A][2], the file extension is `.wgsl`.

PR #2774 

[1]: https://www.w3.org/TR/WGSL/
[2]: https://www.w3.org/TR/WGSL/#text-wgsl-media-type
2024-04-01 23:05:15 -04:00
80007698d3 ignore/types: add Vue
PR #2772
2024-04-01 07:49:29 -04:00
3ad0e83471 ignore/walk: correct build_parallel() documentation
The returned closure should return `WalkState`, not `()`.

Closes #2767
2024-03-27 14:50:05 -04:00
9da0995df4 ignore/types: add 'svelte' to the default file types
Ref: https://svelte.dev/

PR #2759
2024-03-19 13:36:08 -04:00
59212d08d3 style: fix new lints
The Rust compiler seems to have gotten smarter at finding unused or
redundant imports.
2024-03-07 09:37:48 -05:00
2c3897585d ignore-0.4.22 2024-01-06 14:27:44 -05:00
b9c774937f ignore: fix reference cycle for compiled matchers
It looks like there is a reference cycle caused by the compiled
matchers (compiled HashMap holds ref to Ignore and Ignore holds ref
to HashMap). Using weak refs fixes issue #2690 in my test project.
Also confirmed via before and after when profiling the code, see the
attached screenshots in #2692.

Fixes #2690
2024-01-06 12:50:42 -05:00
67dd809a80 ignore: add some 'allow(dead_code)' annotations
I don't usually like doing this and would prefer to just delete unused
code, but I don't have the context required to understand why this code
is unused. A refresh of this crate is on the (distant) horizon, so I'll
just leave these here for now to squash the warnings.
2024-01-06 12:25:06 -05:00
56c7ad175a ignore/types: add Lean
Ref: https://lean-lang.org/

PR #2678
2023-12-07 11:46:00 -05:00
2a4dba3fbf ignore/types: add meson.options
Starting with meson 1.1, there is a preference for using meson.options
instead of meson_options.txt.  Add the new filename to the meson set.

PR #2666
2023-11-29 19:03:12 -05:00
381c521d02 ignore-0.4.21 2023-11-26 14:12:16 -05:00
57495db10e deps: bump globset to 0.4.14 2023-11-26 14:11:43 -05:00
6d7550d58e ignore: Avoid contention on num_pending
Previously, every worker would increment the shared num_pending count on
every new work item, and decrement it after finishing them, leading to
lots of contention.  Now, we only track the number of workers actively
running, so there is no contention except when workers go to sleep or
wake up.

Closes #2642
2023-11-21 18:39:32 -05:00
922bad2b92 ignore: improve 'excludesFile' parsing
This permits the value to be surrounded in double quotes. It's still not
perfect, but probably better than it was. Getting this to be more
correct will likely require writing (or using) a real parser, which I'm
not particularly incliend to do at present.

Fixes #2392, Closes #2629
2023-11-20 23:51:53 -05:00
53679e4c43 ignore: simplify the work-stealing strategy
There's no particular reason for this change. I happened to be looking
at the code again and realized that stealing from your left neighbour
or your right neighbour shouldn't make a difference (and indeed perf is
the same in my benchmarks).

Closes #2624
2023-11-20 23:51:53 -05:00
9626f16757 progress 2023-10-09 20:29:52 -04:00
6d17b3ed68 deps: drop thread_local, lazy_static and once_cell
This is largely made possible by the addition of std::sync::OnceLock to
the standard library, and the memory pool available in regex-automata.
2023-10-09 20:29:52 -04:00
f16ea0812d ignore: polish
Like previous commits, we do a bit of polishing and bring the style up
to my current practice.
2023-10-09 20:29:52 -04:00
3ad7a0d95e crates: remove hard-coded links
And use rustdoc's native intra-crate links. So much nicer.
2023-10-09 20:29:52 -04:00
abfa65c2c1 ignore/types: add *.sarif for SARIF format files
[SARIF] is a format for reporting static analysis results. It is [used
by GitHub CodeQL][GH] for example.

Here are some samples from Microsoft's VSCode extension:

https://github.com/microsoft/sarif-vscode-extension/tree/main/samples

The SARIF format is built on top of JSON.

[SARIF]: https://docs.oasis-open.org/sarif/sarif/v2.1.0/csprd01/sarif-v2.1.0-csprd01.html
[GH]: https://docs.github.com/en/code-security/code-scanning/integrating-with-code-scanning/sarif-support-for-code-scanning

PR #2620
2023-10-05 13:23:29 -04:00
d938e955af ignore: use work-stealing stack instead of Arc<Mutex<Vec<_>>>
This represents yet another iteration on how `ignore` enqueues and
distributes work in parallel. The original implementation used a
multi-producer/multi-consumer thread safe queue from crossbeam. At some
point, I migrated to a simple `Arc<Mutex<Vec<_>>>` and treated it as a
stack so that we did depth first traversal. This helped with memory
usage in very wide directories.

But it turns out that a naive stack-behind-a-mutex can be quite a bit
slower than something that's a little smarter, such as a work-stealing
stack used in this commit. My hypothesis for why this helps is that
without the stealing component, work distribution can get stuck in
sub-optimal configurations that depend on which directory entries get
assigned to a particular worker. It's likely that this can result in
some workers getting "more" work than others, just by chance, and thus
remain idle. But the work-stealing approach heads that off.

This does re-introduce a dependency on parts of crossbeam which is kind
of a bummer, but it's carrying its weight for now.

Closes #1823, Closes #2591
Ref https://github.com/sharkdp/fd/issues/28
2023-09-20 11:52:42 -04:00
cad1f5fae2 ignore: fix filtering when searching subdirectories
When searching subdirectories the path was not correctly built and
included duplicate parts. This fix will remove the duplicate part if
possible.

Fixes #1757, Closes #2295
2023-09-20 11:52:42 -04:00
d596f6ebd0 ignore/types: add *.vsh to V type
PR #2604
2023-08-31 08:51:07 -04:00
6cd9479634 ignore: implement FusedIterator for Walk
PR #2567
2023-08-28 22:55:19 -04:00
51765f2f4c ignore: apply rustfmt
I believe this happened because rustfmt now knows how to format `let ...
else` constructs.
2023-08-28 20:09:26 -04:00
962d47e6a1 ignore/types: add Prolog file types
This improves the Prolog file type rules.

* `.pl` is the most common extension in the wild, though `.pro` is
   preferred in places where file extension may clash with Perl[1].
* `.P` is used for compatibility with XSB Prolog dialect[2].

PR #2590

[1]: https://www.swi-prolog.org/pldoc/man?section=fileext
[2]: https://www.swi-prolog.org/pldoc/man?section=xsb-source
2023-08-21 10:53:56 -04:00
19b6a45abb ignore/types: tweak Gradle file types
This PR extends Gradle file types with the following:

 - Kotlin DSL buildscripts (`*.gradle.kts`)
 - Gradle Java properties (`gradle.properties`)
 - wrapper files (`gradle-wrapper.*`)
 - wrapper scripts (`gradlew`, `gradlew.bat`)

PR #2587
2023-08-20 18:49:02 -04:00
fed4fea217 ignore/types: add csproj
Supports the .NET C# Project file extension.

PR #2575
2023-07-31 07:08:44 -04:00
601e122e9f ignore/types: add Windows Command Prompt files
This PR adds `*.bat` and `*.cmd` file types.

In doing so, it makes a distinction between batch files (old standard
from the MS-DOS era) and command scripts (new flavor - can operate on
batch files, although `*.cmd` is preferred for various reasons, the
main one being batch files will set `ERRORLEVEL` following inconsistent
MS-DOS style rules[1]).

PR #2556

[1]: https://groups.google.com/g/microsoft.public.win2000.cmdprompt.admin/c/XHeUq8oe2wk/m/LIEViGNmkK0J#i106
2023-07-10 15:58:17 -04:00
cb7501ff11 doc: clarify the comment on Worker.work_done
We call `work_done` only once the work has been actually performed
(otherwise `num_pending` could go to 0 before the actual work is done).

Closes #2039
2023-07-08 18:52:42 -04:00
f30a30867e ignore/types: name aliases for file types
We also make py/python, md/markdown and ts/typescript aliases of one
another.

Note that this only introduces aliases at the point where default types
are defined. This just makes them a bit easier to read/write, and also
makes it easier to expose more names that describe the same thing.

Fixes #1857, Closes #1895
2023-07-08 18:52:42 -04:00
7313dca472 ignore/types: add 'typescript' alias for 'ts'
Closes #2009
2023-07-08 18:52:42 -04:00