Signed-off-by: Matthias Lederhofer <redacted>
---
I did not find another way to use patterns starting with -, if it is
possible without the patch please tell me and ignore the patch :)
example:
% git grep -- --bla HEAD HEAD~1 -- --foo
HEAD:--foo/bla:test --bla foo
builtin-grep.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
From: Timo Hirvonen <hidden> Date: 2016-06-15 22:42:31
Matthias Lederhofer [off-list ref] wrote:
Signed-off-by: Matthias Lederhofer <redacted>
---
I did not find another way to use patterns starting with -, if it is
possible without the patch please tell me and ignore the patch :)
example:
% git grep -- --bla HEAD HEAD~1 -- --foo
HEAD:--foo/bla:test --bla foo
@@ -71,6 +71,11 @@ OPTIONS -f <file>:: Read patterns from <file>, one per line.+-e::+ The next parameter is the pattern. This option has to be+ used for patterns starting with - and should be used in+ scripts passing user input to grep.+ `<tree>...`:: Search blobs in the trees for specified patterns.
Signed-off-by: Matthias Lederhofer <redacted>
---
I did not find another way to use patterns starting with -, if it is
possible without the patch please tell me and ignore the patch :)
example:
% git grep -- --bla HEAD HEAD~1 -- --foo
HEAD:--foo/bla:test --bla foo
git grep -e --bla
Perhaps the original patch may be applied anyways for consistency with
the GNU grep? :)
But it's really not important to me and well, having -- twice in the
command line is a bit strange too.
From: Johannes Schindelin <hidden> Date: 2016-06-15 22:42:31
Hi,
On Sun, 25 Jun 2006, Matthias Lederhofer wrote:
+-e::
+ The next parameter is the pattern. This option has to be
+ used for patterns starting with - and should be used in
+ scripts passing user input to grep.
... and by the far the most common use is to pass more than one pattern.
Also, the usage is "[-e] <pattern> [-e <pattern>...]".
Ciao,
Dscho
@@ -71,6 +71,12 @@ OPTIONS -f <file>:: Read patterns from <file>, one per line.+-e::+ The next parameter is a pattern. This option has to be+ used for patterns starting with - and should be used in+ scripts passing user input to grep. You can specify multiple+ patterns which will be combined by or.+ `<tree>...`:: Search blobs in the trees for specified patterns.
... and by the far the most common use is to pass more than one pattern.
Also, the usage is "[-e] <pattern> [-e <pattern>...]".
Here is a patch to allow combination of patterns with 'and' instead of
'or'. This makes it easier to search for combinations of words in a line
without using grep multiple times combined by pipes. So it is still
possible to use -A/-B/-C (something I miss in normal grep). --and
cannot be passed down, so we have to use the built-in version if it is
set.
Documentation/git-grep.txt | 5 ++++-
builtin-grep.c | 17 +++++++++++++----
2 files changed, 17 insertions(+), 5 deletions(-)
@@ -77,6 +77,9 @@ OPTIONS scripts passing user input to grep. You can specify multiple patterns which will be combined by 'or'.+--and::+ Combine multiple patterns by 'and' instead of 'or'.+ `<tree>...`:: Search blobs in the trees for specified patterns.
Signed-off-by: Matthias Lederhofer <redacted>
---
The 'or' as logic or should be marked in the text. I did
that in the patch with --and too so if this is accepted the
documentation should be consistent. Sorry for the noise.
Documentation/git-grep.txt | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
@@ -71,6 +71,12 @@ OPTIONS -f <file>:: Read patterns from <file>, one per line.+-e::+ The next parameter is a pattern. This option has to be+ used for patterns starting with - and should be used in+ scripts passing user input to grep. You can specify multiple+ patterns which will be combined by 'or'.+ `<tree>...`:: Search blobs in the trees for specified patterns.
From: Thomas Glanzmann <hidden> Date: 2016-06-15 22:42:31
Hello,
*AND* more than one pattern. (something I miss in normal grep)
so do I, is it possible to use git-grep outside of git for files that
are not in a repository? Or are there any grep implementations available
which bring this feature to me?
Thomas