Re: [PATCH] git-grep: --and to combine patterns with and instead of or
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Jun 30, 2006, 17:33 UTC
- Message-ID
- <e83n97$973$1@sea.gmane.org>
- In-Reply-To
- <7vpsgqimu7.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
> Matthias Lederhofer <matled@gmx.net> writes:
Show 8 quoted lines
>> 3. Is --near just another subexpression? e.g. search for foo with >> either A or B in the context: >> -e foo --and ( --near A --or --near B ) >> This does not make sense without 1 and 2. > > Ah, interesting. I was thinking --near to be weaker form of --and, > but you made it to be a unary predicate (like --not). That > would be neater.
I think --near _has_ to be non-symmetric binary operator, i.e. first argument specifies line to be found, second argument has to be in context for first line if it is found.
So the above expression would be written as:
-e foo --near \( A --or B \)
BTW. we can make -e equivalent to --or, and empty (default) operator to --and, but of course you have to delimit expression from files, i.e. either
git grep A B C D -- files
or
git grep -e \( A B C D \) files
which would be equivalent to
git grep A --and B --and C --and D files
-- Jakub Narebski Warsaw, Poland ShadeHawk on #git