Comment by oever
Comment by oever 7 hours ago
This week I wrote a small bash function that run ripgrep only on the files that are tracked by git:
rgg() {
readarray -d '' -t FILES < <(git ls-files -z)
rg "${@}" "${FILES[@]}"
}
It speeds up a lot on directories with many binary files and committed dot files. To search the dot files, -uu is needed, but that also tells ripgrep to search the binary files.On repositories with hundreds of files, the git ls-files overhead a bit large.
Can you provide a concrete example where that's faster? ripgrep should generally already be approximating `git ls-files` by respecting gitignore.
Also, `-uu` tells ripgrep to not respect gitignore and to search hidden files. But ripgrep will still skip binary files. You need `-uuu` to also ignore binary files.
I tried playing with your `rgg` function. First problem occurred when I tried it on a checkout the Linux kernel:
OK, so let's just use `xargs`: And compared to just `rg APM_RESUME`: So do you have an example where `git ls-files -z | xargs -0 rg ...` is faster than just `rg ...`?