All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: "René Scharfe" <l.s.r@web.de>,
	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 14:49:07 +0200	[thread overview]
Message-ID: <87h8i0h83g.fsf@evledraar.gmail.com> (raw)
In-Reply-To: <xmqqmurszu2d.fsf@gitster-ct.c.googlers.com>


On Fri, Oct 05 2018, Junio C Hamano wrote:

> 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.

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
on it...

  reply	other threads:[~2018-10-05 12:49 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
2018-10-05 12:49         ` Ævar Arnfjörð Bjarmason [this message]
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h8i0h83g.fsf@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.