On Sat, Sep 29, 2018 at 7:55 AM Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> wrote: > > This --recursive (-r) option does nothing, and is purely here to > appease people who have "grep -r ..." burned into their muscle memory. > > Requested-by: Christoph Berg <myon@xxxxxxxxxx> > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> > --- > > On Sat, Sep 29, 2018 at 4:10 PM Christoph Berg <myon@xxxxxxxxxx> wrote: > > > > I often use "grep -r $pattern" to recursively grep a source tree. If > > that takes too long, I hit ^C and tag "git" in front of the command > > line and re-run it. git then complains "error: unknown switch `r'" > > because "git grep" is naturally recursive. > > > > Could we have "git grep -r" accept the argument for compatibility? > > Other important grep switches like "-i" are compatible, adding -r > > would improve usability. > > I don't have an opinion on this either way, it doesn't scratch my > itch, but hey, why not. Here's a patch to implement it. > > Documentation/git-grep.txt | 6 ++++++ > builtin/grep.c | 3 +++ > t/t7810-grep.sh | 8 ++++++++ > 3 files changed, 17 insertions(+) > > diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt > index a3049af1a3..a1aea8be4e 100644 > --- a/Documentation/git-grep.txt > +++ b/Documentation/git-grep.txt > @@ -290,6 +290,12 @@ providing this option will cause it to die. > Do not output matched lines; instead, exit with status 0 when > there is a match and with non-zero status when there isn't. > > +-r:: > +--recursive:: > + This option does nothing. git-grep is always recursive. This > + noop option is provided for compatibility with the muscle > + memory of people used to grep(1). git-grep is always file/tree recursive, but there is --recurse-submodules which is off by default. Instead of providing a short alias to a noop, we could use -r for submodules. (And if you happen to have no submodules, this is a noop for you)