From: Matthias Lederhofer <matled@gmx.net>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-grep: --and to combine patterns with and instead of or
Date: Fri, 30 Jun 2006 04:25:42 +0200 [thread overview]
Message-ID: <E1Fw8hS-00023y-FY@moooo.ath.cx> (raw)
In-Reply-To: <7vejx7oa3x.fsf@assigned-by-dhcp.cox.net>
So here is my proposal how extended expressions would work:
extended expressions have three operators:
AND, OR (binary), NOT (unary)
extended expressions do not need an extra option. They will be usable
by adding operators between the expressions; a default operator is
used if no operator is specified. The default operator is by default
OR because currently multiple patterns are combined by OR.
OR and AND have precedence, so there are two possibilities, I'd take
the first one.
1. OR, AND:
This will make it easier to read because OR can be skipped:
pat1 pat2 AND pat3 pat4
= pat1 OR pat2 AND pat3 OR pat4
= (pat1 OR pat2) AND (pat3 OR pat4)
2. AND, OR:
This is a bit more logic if you think of AND as * and OR as +.
Parenthesis may be used to explicitly override the default precedence.
With this setup we can add an option -FOO (I don't now how to call it,
it is the --and from the patch) which changes the default operator and
the precedence. With -FOO you'd get AND as default operator and
precedence AND, OR. Without this option it was easy to write the
formula in a conjungtive form (conjunction of disjunctions), now it is
easy to write a disjunctive form (disjunction of conjunctions):
pat1 pat2 OR pat3 pat4
= pat1 AND pat2 OR pat3 AND pat4
= (pat1 AND pat2) OR (pat3 AND pat4)
With all this as plan for extended expressions we may also introduce
-FOO now with exactly the behaviour of --and in my patch because
currently no explicit operators and parenthesis are allowed, so only
the default operator may be used and -FOO would change the default
operator.
A short example:
(pat1 AND pat2 AND pat3) OR pat4
could be written as
-FOO pat1 pat2 pat3 OR pat4
which is imho quite readable.
So the next problem are names for the options. We would need
- AND: between patterns
- OR: between patterns
- NOT: before a pattern
- FOO: change default operator and precedence
Unfortunately -o, -a, -n are taken and I think the options should be
unique even though they are only allowed at certain positions of the
argument list. I'll think about it a bit, perhaps someone else has a
good idea. FOO should not be named --and imo but I don't have any idea
for a good name atm.
next prev parent reply other threads:[~2006-06-30 2:25 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-25 15:38 [PATCH] git-grep: allow patterns starting with - Matthias Lederhofer
2006-06-25 15:47 ` Timo Hirvonen
2006-06-25 16:07 ` [PATCH] correct documentation for git grep Matthias Lederhofer
2006-06-25 23:10 ` Johannes Schindelin
2006-06-25 23:39 ` Matthias Lederhofer
2006-06-26 0:06 ` Matthias Lederhofer
2006-06-26 6:59 ` Johannes Schindelin
2006-06-26 0:02 ` [PATCH] git-grep: --and to combine patterns with and instead of or Matthias Lederhofer
2006-06-29 22:20 ` Thomas Glanzmann
2006-06-29 22:44 ` Junio C Hamano
2006-06-30 2:25 ` Matthias Lederhofer [this message]
2006-06-30 4:13 ` Junio C Hamano
2006-06-30 7:46 ` Matthias Lederhofer
2006-06-30 7:56 ` Junio C Hamano
2006-06-30 10:08 ` [PATCH] git-grep: boolean expression on pattern matching Junio C Hamano
2006-06-30 10:24 ` Jakub Narebski
2006-06-30 10:29 ` Junio C Hamano
2006-06-30 15:11 ` Matthias Lederhofer
2006-06-30 10:57 ` [PATCH] git-grep: --and to combine patterns with and instead of or Matthias Lederhofer
2006-06-30 15:57 ` Junio C Hamano
2006-06-30 17:04 ` Matthias Lederhofer
2006-06-30 17:18 ` Junio C Hamano
2006-06-30 17:33 ` Jakub Narebski
2006-06-30 17:49 ` Matthias Lederhofer
2006-06-30 17:58 ` Junio C Hamano
2006-06-30 18:20 ` Matthias Lederhofer
2006-06-30 18:03 ` Jakub Narebski
2006-06-30 18:16 ` Junio C Hamano
2006-06-30 19:11 ` Jakub Narebski
2006-06-30 20:26 ` Junio C Hamano
2006-07-03 7:54 ` Andreas Ericsson
2006-06-25 16:18 ` [PATCH] git-grep: allow patterns starting with - Matthias Lederhofer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1Fw8hS-00023y-FY@moooo.ath.cx \
--to=matled@gmx.net \
--cc=git@vger.kernel.org \
--cc=junkio@cox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).