Re: [PATCH] grep: provide a noop --recursive option
- Date: Fri, 05 Oct 2018 14:49:07 +0200
- From: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
- Subject: Re: [PATCH] grep: provide a noop --recursive option
On Fri, Oct 05 2018, Junio C Hamano wrote:
> René Scharfe <l.s.r@xxxxxx> 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)
>> 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),
> 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.
FWIW I'm not going to carry this series forward, I wrote it more as a
"here's how this could be done". But if Christoph / René wants to hack