Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- May 14, 2014, 18:15 UTC
- Message-ID
- <vpqha4sfcqw.fsf@anie.imag.fr>
- In-Reply-To
- <xmqq7g5okztp.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 30 quoted lines
> Stepan Kasal <kasal@ucw.cz> writes:
>
>> From: Johannes Schindelin <johannes.schindelin@gmx.de>
>> Date: Tue, 8 Feb 2011 00:17:24 -0600
>>
>> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
>> Signed-off-by: Stepan Kasal <kasal@ucw.cz>
>> ---
>> Hi,
>> this patch has been in msysgit for 3 1/4 years.
>> Stepan
>>
>> builtin/grep.c | 3 +++
>> 1 file changed, 3 insertions(+)
>>
>> diff --git a/builtin/grep.c b/builtin/grep.c
>> index 8073fbe..6c82a29 100644
>> --- a/builtin/grep.c
>> +++ b/builtin/grep.c
>> @@ -897,6 +897,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
>> if (len > 4 && is_dir_sep(pager[len - 5]))
>> pager += len - 4;
>>
>> + if (opt.ignore_case && !strcmp("less", pager))
>> + string_list_append(&path_list, "-i");
>
> I have a feeling that this goes against the recent trend of not
> mucking with the expectation of the users on their pagers, if I
> recall correctly the arguments for dropping S from the default given
> to an unconfigured LESS environment variable.I had the same feeling about "we're doing magic in corner-cases, makes it hard for the user to understand what's going on". But the patch actually makes a lot of sense. Without the patch, I get
$ git grep -O -i no_openssl Pattern not found (press RETURN)
with the patch, I do get a file opened and NO_OPENSSL selected.
The lines right below the ones of the patch are aleady (documented) less+vi magic, which actually require the patch to behave well in the presence of -i.
-- Matthieu Moy http://www-verimag.imag.fr/~moy/