From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
git@vger.kernel.org, "Christoph Berg" <myon@debian.org>,
"Duy Nguyen" <pclouds@gmail.com>
Subject: Re: [PATCH] grep: provide a noop --recursive option
Date: Fri, 05 Oct 2018 01:17:14 -0700 [thread overview]
Message-ID: <xmqqmurszu2d.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: ffc574a9-cf78-2dd5-084a-a6005547d363@web.de
René Scharfe <l.s.r@web.de> writes:
>
> Recognize -r and --recursive as synonyms for --max-depth=-1 for
> compatibility with GNU grep; it's still the default for git grep.
>
> This also adds --no-recursive as synonym for --max-depth=0 for free,
> which is welcome for completeness and consistency.
>
> Fix the description for --max-depth, while we're at it -- negative
> values other than -1 actually disable recursion, i.e. they are
> equivalent to --max-depth=0.
> ...
> diff --git a/builtin/grep.c b/builtin/grep.c
> index 601f801158..f6e127f0bc 100644
> --- a/builtin/grep.c
> +++ b/builtin/grep.c
> @@ -811,6 +811,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
> GREP_BINARY_NOMATCH),
> OPT_BOOL(0, "textconv", &opt.allow_textconv,
> N_("process binary files with textconv filters")),
> + OPT_SET_INT('r', "recursive", &opt.max_depth,
> + N_("search in subdirectories (default)"), -1),
Wow.
I didn't think of this trick to let OPT_SET_INT() to grok --no-* and
set the variable to 0. Being able to do this without a custom
callback is certainly very nice.
The patch looks good.
Thanks.
next prev parent reply other threads:[~2018-10-05 8:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-29 14:01 wishlist: git grep -r Christoph Berg
2018-09-29 14:55 ` [PATCH] grep: provide a noop --recursive option Ævar Arnfjörð Bjarmason
2018-09-29 15:08 ` Duy Nguyen
2018-09-29 15:25 ` Ævar Arnfjörð Bjarmason
2018-09-29 15:47 ` Duy Nguyen
2018-09-29 17:11 ` Junio C Hamano
2018-09-29 19:38 ` Christoph Berg
2018-10-01 19:15 ` René Scharfe
2018-10-05 8:17 ` Junio C Hamano [this message]
2018-10-05 12:49 ` Ævar Arnfjörð Bjarmason
2018-10-01 19:23 ` Stefan Beller
2018-10-05 8:15 ` Christoph Berg
2018-10-05 8:19 ` Junio C Hamano
2018-10-05 13:05 ` Mischa POSLAWSKY
2018-10-05 19:17 ` Stefan Beller
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqmurszu2d.fsf@gitster-ct.c.googlers.com \
--to=gitster@pobox.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
--cc=myon@debian.org \
--cc=pclouds@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).