Subject: Re: [PATCH v4 2/2] builtin/grep: add grep.fallbackToNoIndex config

From: Thomas Gummerer <[email-masked]>
Date: Tue, 12 Jan 2016 16:50:05 +0100

On 01/12, Jeff King wrote:
> On Tue, Jan 12, 2016 at 11:40:26AM +0100, Thomas Gummerer wrote:
>
> > diff --git a/builtin/grep.c b/builtin/grep.c
> > index 4229cae..6b7add6 100644
> > --- a/builtin/grep.c
> > +++ b/builtin/grep.c
> > @@ -755,9 +755,15 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
> >  			     PARSE_OPT_STOP_AT_NON_OPTION);
> >  	grep_commit_pattern_type(pattern_type_arg, &opt);
> >
> > -	if (use_index && !startup_info->have_repository)
> > -		/* die the same way as if we did it at the beginning */
> > -		setup_git_directory();
> > +	if (use_index && !startup_info->have_repository) {
> > +		int fallback = 0;
> > +		git_config_get_bool("grep.fallbacktonoindex", &fallback);
> > +		if (fallback)
> > +			use_index = 0;
> > +		else
> > +			/* die the same way as if we did it at the beginning */
> > +			setup_git_directory();
> > +	}
> >
> >  	/*
> >  	 * skip a -- separator; we know it cannot be
>
> Nice. This turned out delightfully simple.

Indeed, much simpler than I expected.  Thanks for the help getting it there.

> -Peff