It really just depends. The way I like to characterize `git grep` (at present) is that it has sharp performance cliffs. ripgrep has them too, to be sure, but I think it has fewer of them.
If you're just searching for a simple literal, `git grep` is decently fast:
But if you switch it up and start adding regex things to your pattern, there can be substantial slowdowns:
$ time LC_ALL=C git grep -c -E '\w{5,}\s+PM_RESUME'
Documentation/dev-tools/sparse.rst:1
Documentation/translations/zh_CN/dev-tools/sparse.rst:1
Documentation/translations/zh_TW/sparse.txt:1
real 5.704
user 55.671
sys 0.585
maxmem 207 MB
faults 0
$ time LC_ALL=en_US.UTF-8 git grep -c -E '\w{5,}\s+PM_RESUME'
Documentation/dev-tools/sparse.rst:1
Documentation/translations/zh_CN/dev-tools/sparse.rst:1
Documentation/translations/zh_TW/sparse.txt:1
real 24.529
user 4:34.42
sys 0.753
maxmem 211 MB
faults 0
$ time LC_ALL=en_US.UTF-8 git grep -c -P '\w{5,}\s+PM_RESUME'
Documentation/dev-tools/sparse.rst:1
Documentation/translations/zh_CN/dev-tools/sparse.rst:1
Documentation/translations/zh_TW/sparse.txt:1
real 1.372
user 16.980
sys 0.647
maxmem 211 MB
faults 1
$ time rg -c '\w{5,}\s+PM_RESUME'
Documentation/translations/zh_CN/dev-tools/sparse.rst:1
Documentation/dev-tools/sparse.rst:1
Documentation/translations/zh_TW/sparse.txt:1
real 0.082
user 0.226
sys 0.612
maxmem 18 MB
faults 0
In the above cases, ripgrep has Unicode enabled. (It's enabled by default irrespective of locale settings. ripgrep doesn't interact with POSIX locales at all.)
Thanks for clarifying! I use `git grep -IPn --color=always --recurse-submodules` many times a day, every day. I hasn't yet let me down, but I don't search for unicode when working on source code. I do use regex though, using the -P switch.
It really just depends. The way I like to characterize `git grep` (at present) is that it has sharp performance cliffs. ripgrep has them too, to be sure, but I think it has fewer of them.
If you're just searching for a simple literal, `git grep` is decently fast:
But if you switch it up and start adding regex things to your pattern, there can be substantial slowdowns: In the above cases, ripgrep has Unicode enabled. (It's enabled by default irrespective of locale settings. ripgrep doesn't interact with POSIX locales at all.)