Re: [PATCH v1 1/2] string: Add strprefix(), and deprecate str_has_prefix()

From: Linus Torvalds

Date: Thu Nov 05 2026 - 18:23:13 EST


On Thu, 5 Nov 2026 at 14:25, Alejandro Colomar <alx@xxxxxxxxxx> 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?

"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.

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.

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.

So just embrace "git grep". I can pretty much guarantee that if you
use it a while you'll never go back.

Linus