Re: [PATCH] git-grep: --and to combine patterns with and instead of or
- From
Jakub Narebski <jnareb@gmail.com>
- Date
- Jun 30, 2006, 18:03 UTC
- Message-ID
- <e83p0q$dla$1@sea.gmane.org>
- In-Reply-To
- <E1FwN7M-0007GI-Ng@moooo.ath.cx>
Matthias Lederhofer wrote:
Show 13 quoted lines
> Jakub Narebski wrote: >> 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 \) > Why is that? > -e foo --and --near \( -e A --or -e B \) > would mean lines containing foo and either A or B in the context and > -e foo --or --near \( -e A --or -e B \) > would mean lines containing foo or having A or B in the context.
Because --near needs an expression it check context for (context is for found match of lhs expression). So
-e foo --near \( -e A --or -e B \)
means lines containing foo and either A or B in the context _for "foo"_.
--and --near could be shorthand for --and-near, and --or --near for --or-near... except that the second one doesn't have much sense:
What is the difference between -e foo --or --near \( -e A --or -e B \) and -e foo --or \( -e A --or -e B \)
-- Jakub Narebski Warsaw, Poland ShadeHawk on #git