`gitconfig_excludes_path()` resolves the global gitignore
by reading `core.excludesFile` from `$HOME/.gitconfig` and
`$XDG_CONFIG_HOME/git/config`, but git 2.32 (June 2021) introduced
`GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM` environment variables that
override these locations. The `ignore` crate doesn't check either of
them, so users who point `GIT_CONFIG_GLOBAL` at a non-standard path
(e.g. NixOS managing git config at `/etc/git/config`) have their global
gitignore silently ignored by ripgrep while `git` itself respects it.
This commit checks `GIT_CONFIG_GLOBAL` before the hardcoded paths,
matching git's semantics where it replaces both `$HOME/.gitconfig` and
the XDG config. It also adds system-level config (`GIT_CONFIG_SYSTEM`,
falling back to `/etc/gitconfig`) as a lowest-priority source for
`core.excludesFile`, which the crate previously didn't consult at all.
Fixes#3275, Closes#3276
Note that we continue to disable memory maps on macOS.
Note also that I've generally been unable to observe a performance
improvement from a change like this. However, I think it's fine to do
this for reasons of "good sense."
Closes#3246
This used to be Coq, but the language got renamed:
https://rocq-prover.org/about#Name
Interestingly, there is no mention of the pronunciation of the name in
English speaking countries.
Closes#3357
Make sure that we correctly check that all globs are matched, even if
multiple globs use the same strategy.
Previously we only checked that all strategies matched, but didn't
check with the strategies themselves.
This now adds a `matches_all` method to each strategy to check all
globs within a strategy.
This avoids allocating for tracking the number of matches.
Fixes#3290, Closes#3302
On Windows probing the existence of each ignore file is
very heavy. Windows prefers fetching metadata in batches
(FindFirstFileExW/FindNextFileW, which translates to
std::sys::fs::read_dir)
Now, in ignore::Work::read_dir, we read the entire directory at once,
then use the result to determine the existense of ignore files. The
result is saved and visited later. This avoids stat'ing file paths that
don't exist.
Note that this also helps with Linux workloads too. For example, on
the <https://github.com/NightMachinary/r_HPfanfiction> repository:
```
$ hyperfine "rg-base 'with regexes,'" "rg-test 'with regexes,'"
Benchmark 1: rg-base 'with regexes,'
Time (mean ± σ): 483.1 ms ± 6.4 ms [User: 2493.1 ms, System: 3192.9 ms]
Range (min … max): 474.8 ms … 496.0 ms 10 runs
Benchmark 2: rg-test 'with regexes,'
Time (mean ± σ): 350.4 ms ± 5.2 ms [User: 1652.6 ms, System: 2324.5 ms]
Range (min … max): 341.6 ms … 358.5 ms 10 runs
Summary
rg-test 'with regexes,' ran
1.38 ± 0.03 times faster than rg-base 'with regexes,'
```
Fixes#3293, Closes#3410
Parent ignore matchers are cached by directory across search roots, but
each root must keep its own absolute_base for path rewriting when applying
parent .gitignore / .rgignore rules. Document that invariant and lock it
in with unit and integration tests for the order-dependent multi-root
bugs in #3376, #3419, and #3320.
Closes#3320, Closes#3376, Ref #3419, Closes#3451
- eliminate no_function_argzero. was only needed for old versions of zsh
that lacked ZSH_ARGZERO
- fix misc. style/convention issues
- improve error messages
- eliminate redundant `diff --label` condition. the gnu diff
documentation implies that it doesn't support -L, but it does
- test hidden ('!') arg specs. i may have been worried that hidden
options wouldn't be mentioned in the help output, but this isn't
actually a problem atm. we can re-assess if it becomes one in the
future
- move to separate functions. we're already using type functions for the
other actions so we might as well do it for these. it makes the main
function a lot cleaner
- improve weird colour-spec conditions
- don't suffix 'none' attribute with colon
- improve completion of second part of type spec. (i don't think my
comment about it being complex was true, i was either ignorant or
unimaginative)
- general clean-up etc
these weren't really necessary, it's self-evident what the groups are
for. rather than add more superfluous comments for the groups added in
my previous commit, we can just get rid of them
i think these options didn't have their own groups because originally
there weren't --no-* variants for them. now there are, and they should
be mutually exclusive
when this function was first written, the _arguments grouping feature
(added in zsh 5.4) was new enough that compatibility with older shells
was a real concern. but it's been almost a decade (!) since then so i
think it's fine to just assume we have it now
Include the depth in I/O errors from WalkDir as well, so that the
consumer can handle the error differently depending on depth. For
example, this would allow ignoring broken symlinks that don't match
certain depth criteria.
Note that this could conceivably be a breaking change if callers
were previously relying on down-casting nested errors to specific
types. There weren't any documented API guarantees around this,
but if it breaks too many folks, we'll likely need to back this out.
Fixes#3453
Parent matchers are cached by directory, but they also stored the
canonicalized path passed to `Ignore::add_parents`. Reusing cached
matchers while walking another root could therefore rewrite paths
relative to the wrong root and apply scoped parent gitignore rules
incorrectly.
Keep the cached matcher chain independent of the walk root. Carry the
absolute base path in `Ignore` instead, and add a regression test that
checks cached parent matchers can be reused across roots without sharing
their path semantics.
Fixes#3419