Hi Linus, > Date: 2026-11-05 15:21:35-0800 > From: Linus Torvalds > > On Thu, 5 Nov 2026 at 14:25, Alejandro Colomar wrote: > > > > I'm not a fan of git-grep(1), because it's easier to remember grep(1), > > as I already need to remember it for other stuff. > > Why? Perhaps it's fear of the unknown. 'find | xargs grep' has always worked just fine. > "git grep" is *literally* the exact same thing as "git ls-files | > xargs grep" that you apparently find so natural. It takes all the same > arguments as "grep" does. Hmmmm, if it's literally exactly the same thing, I guess I'll give it a try. I was probably worried that it might have subtle issues, but being morally the same, it's comforting. > Except "git grep" is way more capable if you ever go "Oh, but I'd like > to go back to an older version". > > That makes no sense. > > > I'm finding some issues with git-ls-files(1), though: it's listing > > symlinks, which grep(1) complains about. I wish I could discard those > > with something like '-type f'. > > Christ. > > "Doctor, doctor, it hurts when I hit myself in the face with a spiky object". :-) > > Stop doing that. You're just being silly for no reason. > > > $ time git ls-files | xargs grep ARRAY_SIZE | wc -l > > Just do the sane thing. Look: > > git grep ARRAY_SIZE | wc -l > > Trust me. Just learn to write "git grep". After five minutes of doing > that, you'll realize that you should always have done it, and you were > silly thinking anything else. I'll trust you; I'll give it a try. :) > > And it's faster too: > > $ time git ls-files | xargs grep ARRAY_SIZE 2&>1 > /dev/null > > real 0m0.636s > user 0m0.367s > sys 0m0.307s > > $ time git grep ARRAY_SIZE > /dev/null > > real 0m0.519s > user 0m1.837s > sys 0m1.719s > > (I used that "2&>1" to obviously remove the errors from the stupid > mis-used of xargs). > > And it's *safer* too, because if you have filenames with spaces, "git > grep" does the right thing. Your xargs thing now needs to start using > "-z" to git ls-files and "-0" to grep to actually be safe. Yup, I don't have file names with spaces, because of this (and many other scripts). > So just embrace "git grep". I can pretty much guarantee that if you > use it a while you'll never go back. Ok. Thanks! I'll try it. :) Cheers, Alex > > Linus --