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 19:04:15 +0200 [thread overview]
Message-ID: <E1FwMPf-0005XA-N9@moooo.ath.cx> (raw)
In-Reply-To: <7vejx6k54p.fsf@assigned-by-dhcp.cox.net>
> Side note. It would be interesting to have a slightly different
> form of --and called --near. You would use it like this:
>
> git grep -C -e AND --near -e OR
>
> to find lines that has AND on it, and within the context
> distance there is a line that has OR on it. The lines that are
> hit with such a query are still the ones that have AND on them
> (in other words, a line that has OR is used to further filter
> out the results so it will be prefixed with '-', not ':', unless
> that line happens to also have AND on it).
Nice idea even though I don't now about practical importance but it
sounds quite handy. A few questions about this (some or all of those
features may make it quite complex):
1. Should the context of near be the same as -[ABC] or perhaps
--near=N / --near=N:M (default could be the same as specified by
-[ABC]).
2. Should it be possible to specify another boolean expression after
--near? e.g. --near ( -e foo --or ( -e bar --and -e baz )) to match
if the context contains foo or 'bar and baz'.
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.
With some or all of those features quite mighty and complex
expressions can be build:
-e A --and --near=3:-1 ( -e B --and --near=0:0 ( -e foo --and -e bar ) )
This could mean: find lines containing A and have B in any of the 3
lines before A (without the line containing A). Additionally foo and
bar have to be found on the same line before A.
I'm really not asking for this, just telling about some ideas that
come to my mind for --near.
> With your syntax perhaps this is spelled as "--near -C -e AND -e
> OR".
Huh? What do you mean by "my syntax"? The only thing different is the
option to change the default operator to 'and'.
With the new extended expressions it would be really nice if git-grep
could also be used outside a git repository :)
next prev parent reply other threads:[~2006-06-30 17:04 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
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 [this message]
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=E1FwMPf-0005XA-N9@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).