Re: [PATCH] grep --no-index: allow use of "git grep" outside a git repository

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Jan 15, 2010 at 05:05:42PM -0800, Junio C Hamano wrote:

> > Out of curiosity, what are the interesting features in git grep versus
> > other greps?
> 
> Three examples:
> 
>     git grep -e Junio --and -e Dscho --and -e Peff
> 
> is different from
> 
>     grep "Junio.*Dscho.*Peff"

Right. I would do:

  grep Junio | grep Dscho | grep Peff

No, it's not quite as accurate, as you are grepping the filenames too.

And no, it's not as efficient, but given that the first grep eliminates
most of your input anyway, it's generally not a big deal.

So the short answer to my question seems to be "git grep has logical
operators". I don't find that compelling, but I guess some people do.
Thanks for satisfying my curiosity.

> I don't know how you would do these with "grep":
> 
>     git grep -e Junio --and -e Dscho --and --not -e Linus

I would do "grep Junio | grep Dscho | grep -v Linus".

>     git grep --all-match -e Junio -e Dscho

That one is a little harder (though it is not something I do very often,
and I had to actually read the docs to find what --all-match does):

  grep Junio `grep -l Dscho *`

which of course has problems with exotic filenames.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]