# [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option

14 messages from 2014-05-14 to 2014-05-15. Participants: Stepan Kasal, Junio C Hamano, Matthieu Moy, Jonathan Nieder, Jeff King, Johannes Schindelin.
Thread: https://gitlist.dev/t/36656

## Stepan Kasal, 2014-05-14 15:50

Subject: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140514155010.GA4592@camelia.ucw.cz>
URL: https://gitlist.dev/e/20140514155010.GA4592%40camelia.ucw.cz

```
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");
+
 		if (!strcmp("less", pager) || !strcmp("vi", pager)) {
 			struct strbuf buf = STRBUF_INIT;
 			strbuf_addf(&buf, "+/%s%s",
-- 
1.9.2.msysgit.0.335.gd2a461f

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Junio C Hamano, 2014-05-14 17:57

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <xmqq7g5okztp.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqq7g5okztp.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20140514155010.GA4592@camelia.ucw.cz>

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

>  		if (!strcmp("less", pager) || !strcmp("vi", pager)) {
>  			struct strbuf buf = STRBUF_INIT;
>  			strbuf_addf(&buf, "+/%s%s",
> -- 
> 1.9.2.msysgit.0.335.gd2a461f
>
> -- 

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Matthieu Moy, 2014-05-14 18:15

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <vpqha4sfcqw.fsf@anie.imag.fr>
URL: https://gitlist.dev/e/vpqha4sfcqw.fsf%40anie.imag.fr
In-Reply-To: <xmqq7g5okztp.fsf@gitster.dls.corp.google.com>

```
Junio C Hamano <gitster@pobox.com> writes:

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

```

## Jonathan Nieder, 2014-05-14 18:26

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140514182654.GA9218@google.com>
URL: https://gitlist.dev/e/20140514182654.GA9218%40google.com
In-Reply-To: <xmqq7g5okztp.fsf@gitster.dls.corp.google.com>

```
Hi,

Junio C Hamano wrote:
> Stepan Kasal <kasal@ucw.cz> writes:

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

It's just missing an explanation.

When <command> happens to be the magic string "less", today

	git grep -O<command> -e<pattern>

helpfully passes +/<pattern> to less so you can navigate through
the results within a file using the n and shift+n keystrokes.

Alas, that doesn't do the right thing for a case-insensitive match.
For that case we should pass --IGNORE-CASE to "less" so that n and
shift+n can move between results ignoring case in the pattern.
(That's -I, not -i, because it ought to work even when the pattern
contains capital letters.)

"git grep" has other options that affect interpretation of the pattern
which this patch does not help with:

 * -v / --ignore-match: probably should disable this feature of -O.
 * -E / --extended-regexp
 * -P / --perl-regexp
 * -F / --fixed-strings: ideally would auto-escape regex specials.
 * -e<pattern1> --or -e<pattern2>

And git grep -Ovi has a similar bug, for which the fix is to add
\c to the pattern instead of passing an -I option.

But as is, it's an improvement, so (except that "-i" should be
replaced by "-I") it seems like a good change.

Hope that helps,
Jonathan

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Junio C Hamano, 2014-05-14 18:33

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <xmqqvbt8jjlg.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqvbt8jjlg.fsf%40gitster.dls.corp.google.com
In-Reply-To: <20140514182654.GA9218@google.com>

```
Jonathan Nieder <jrnieder@gmail.com> writes:

>>> +		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.
>
> It's just missing an explanation.
> ...
> (That's -I, not -i, because it ought to work even when the pattern
> contains capital letters.)

Spot on.  The change, especially with "-I", makes sense.

Thanks.

```

## Stepan Kasal, 2014-05-14 18:35

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140514183527.GA5422@camelia.ucw.cz>
URL: https://gitlist.dev/e/20140514183527.GA5422%40camelia.ucw.cz
In-Reply-To: <20140514182654.GA9218@google.com>

```
Hello,

On Wed, May 14, 2014 at 11:26:54AM -0700, Jonathan Nieder wrote:
> But as is, it's an improvement, so (except that "-i" should be
> replaced by "-I") it seems like a good change.

indeed, "-I" would match the semantics of git-grep -i .

Stepan

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Jeff King, 2014-05-14 19:07

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140514190716.GA2715@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20140514190716.GA2715%40sigill.intra.peff.net
In-Reply-To: <20140514182654.GA9218@google.com>

```
On Wed, May 14, 2014 at 11:26:54AM -0700, Jonathan Nieder wrote:

> "git grep" has other options that affect interpretation of the pattern
> which this patch does not help with:
> 
>  * -v / --ignore-match: probably should disable this feature of -O.
>  * -E / --extended-regexp
>  * -P / --perl-regexp
>  * -F / --fixed-strings: ideally would auto-escape regex specials.
>  * -e<pattern1> --or -e<pattern2>
> 
> And git grep -Ovi has a similar bug, for which the fix is to add
> \c to the pattern instead of passing an -I option.

We've already found the lines of interest to the user. It would be nice
if we could somehow point the pager at them by number, rather than
repeating the (slightly incompatible) search.

We can do "less +25", but that only points it to the first instance (and
doesn't highlight it), whereas the current code lets the repeat-search
find other instances. I don't think there's a way to queue up a set of
interesting lines to visit in less. At least I could not think of one.

This is more or less how I ended up at the design of contrib/git-jump,
which uses quickfix lists to make such a queue (only editors
understand those, not pagers, but I consider being dumped into the
editor a feature :) ).

> But as is, it's an improvement, so (except that "-i" should be
> replaced by "-I") it seems like a good change.

Agreed. Thanks for the list of problematic options.

-Peff

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Johannes Schindelin, 2014-05-15 17:44

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <alpine.DEB.1.00.1405151943310.14982@s15462909.onlinehome-server.info>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1405151943310.14982%40s15462909.onlinehome-server.info
In-Reply-To: <xmqqvbt8jjlg.fsf@gitster.dls.corp.google.com>

```
Hi Junio,

On Wed, 14 May 2014, Junio C Hamano wrote:

> Jonathan Nieder <jrnieder@gmail.com> writes:
> 
> >>> +		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.
> >
> > It's just missing an explanation.
> > ...
> > (That's -I, not -i, because it ought to work even when the pattern
> > contains capital letters.)
> 
> Spot on.  The change, especially with "-I", makes sense.

Except that it was not tested with -I. If you change it that way and it
stops working on Windows, it's useless to me.

Ciao,
Johannes

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Johannes Schindelin, 2014-05-15 17:46

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <alpine.DEB.1.00.1405151944410.14982@s15462909.onlinehome-server.info>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1405151944410.14982%40s15462909.onlinehome-server.info
In-Reply-To: <20140514190716.GA2715@sigill.intra.peff.net>

```
Hi Peff,

On Wed, 14 May 2014, Jeff King wrote:

> On Wed, May 14, 2014 at 11:26:54AM -0700, Jonathan Nieder wrote:
> 
> > "git grep" has other options that affect interpretation of the pattern
> > which this patch does not help with:
> > 
> >  * -v / --ignore-match: probably should disable this feature of -O.
> >  * -E / --extended-regexp
> >  * -P / --perl-regexp
> >  * -F / --fixed-strings: ideally would auto-escape regex specials.
> >  * -e<pattern1> --or -e<pattern2>
> > 
> > And git grep -Ovi has a similar bug, for which the fix is to add
> > \c to the pattern instead of passing an -I option.
> 
> We've already found the lines of interest to the user. It would be nice
> if we could somehow point the pager at them by number, rather than
> repeating the (slightly incompatible) search.

FWIW it is exactly that type of "I want your patch to do more than you do"
type of comments that makes it impossible for myself to contribute patches
anymore. It just does not fit inside my Git time budget anymore.

Besides, it breaks exactly the intended usage. My intent is not just to
see the matching lines in the pager, but to be able to adjust the search
pattern further if needed. Your suggestion completely breaks that usage.

Ciao,
Johannes

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Jonathan Nieder, 2014-05-15 17:53

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140515175344.GM9218@google.com>
URL: https://gitlist.dev/e/20140515175344.GM9218%40google.com
In-Reply-To: <alpine.DEB.1.00.1405151943310.14982@s15462909.onlinehome-server.info>

```
Hi,

Johannes Schindelin wrote:
> On Wed, 14 May 2014, Junio C Hamano wrote:

>> Spot on.  The change, especially with "-I", makes sense.
>
> Except that it was not tested with -I. If you change it that way and it
> stops working on Windows, it's useless to me.

Are you saying that less on Windows doesn't have an "-I" option?
version.c tells me it was added in v266 (1994-12-26).

If "-I' is in fact broken on Windows, that would be useful to know,
but it's not clear to me.  Or if I have misunderstood what

	git grep -i -Oless -eGit_

is supposed to do, that would help, too.

Puzzled,
Jonathan

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Jonathan Nieder, 2014-05-15 17:56

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140515175614.GN9218@google.com>
URL: https://gitlist.dev/e/20140515175614.GN9218%40google.com
In-Reply-To: <alpine.DEB.1.00.1405151944410.14982@s15462909.onlinehome-server.info>

```
Johannes Schindelin wrote:
> On Wed, 14 May 2014, Jeff King wrote:

>> We've already found the lines of interest to the user. It would be nice
>> if we could somehow point the pager at them by number, rather than
>> repeating the (slightly incompatible) search.
>
> FWIW it is exactly that type of "I want your patch to do more than you do"
> type of comments that makes it impossible for myself to contribute patches
> anymore.

I think you're overreacting to Peff's "It would be nice".

It is a way of talking about where this lies in a design space that
also includes the git-jump tool that Peff worked on.  Maybe the tools
can learn from each other.  It is not a reason not to apply the patch.

Jonathan

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Johannes Schindelin, 2014-05-15 19:01

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <alpine.DEB.1.00.1405152100350.14982@s15462909.onlinehome-server.info>
URL: https://gitlist.dev/e/alpine.DEB.1.00.1405152100350.14982%40s15462909.onlinehome-server.info
In-Reply-To: <20140515175344.GM9218@google.com>

```
Hi,

On Thu, 15 May 2014, Jonathan Nieder wrote:

> Johannes Schindelin wrote:
> > On Wed, 14 May 2014, Junio C Hamano wrote:
> 
> >> Spot on.  The change, especially with "-I", makes sense.
> >
> > Except that it was not tested with -I. If you change it that way and it
> > stops working on Windows, it's useless to me.
> 
> Are you saying that less on Windows doesn't have an "-I" option?

I did not say that.

> version.c tells me it was added in v266 (1994-12-26).

Thanks. That was the thing I was really looking for: an indication that -I
is not a new-fangled thing but a well-tested option that even old greps
have.

Ciao,
Dscho

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Jeff King, 2014-05-15 19:18

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <20140515191824.GB29746@sigill.intra.peff.net>
URL: https://gitlist.dev/e/20140515191824.GB29746%40sigill.intra.peff.net
In-Reply-To: <alpine.DEB.1.00.1405151944410.14982@s15462909.onlinehome-server.info>

```
On Thu, May 15, 2014 at 07:46:49PM +0200, Johannes Schindelin wrote:

> > We've already found the lines of interest to the user. It would be nice
> > if we could somehow point the pager at them by number, rather than
> > repeating the (slightly incompatible) search.
> 
> FWIW it is exactly that type of "I want your patch to do more than you do"
> type of comments that makes it impossible for myself to contribute patches
> anymore. It just does not fit inside my Git time budget anymore.

I'm sorry you took it that way. What I meant to say was "it would be
nice if we could do it this other way, which is more robust, but I don't
think it is easy.  Let's take the patch". I.e., when I later said:

>>> But as is, it's an improvement, so (except that "-i" should be
>>> replaced by "-I") it seems like a good change.
>>
>>Agreed. Thanks for the list of problematic options.

the "agreed" there is with "it seems like a good change".

And I also wanted to point people to existing work, if they did want to
explore doing it that other way.  I really didn't expect anything from
you (beyond s/i/I/, as Jonathan suggested).

> Besides, it breaks exactly the intended usage. My intent is not just to
> see the matching lines in the pager, but to be able to adjust the search
> pattern further if needed. Your suggestion completely breaks that usage.

Thanks, this is a point I hadn't considered.

-Peff

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```

## Junio C Hamano, 2014-05-15 19:48

Subject: Re: [PATCH] git grep -O -i: if the pager is 'less', pass the '-i' option
Message-ID: <xmqqha4qesbj.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqha4qesbj.fsf%40gitster.dls.corp.google.com
In-Reply-To: <alpine.DEB.1.00.1405151943310.14982@s15462909.onlinehome-server.info>

```
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:

>> Jonathan Nieder <jrnieder@gmail.com> writes:
>> 
>> >>> +		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.
>> >
>> > It's just missing an explanation.
>> > ...
>> > (That's -I, not -i, because it ought to work even when the pattern
>> > contains capital letters.)
>> 
>> Spot on.  The change, especially with "-I", makes sense.
>
> Except that it was not tested with -I. If you change it that way and it
> stops working on Windows, it's useless to me.

That is all true, and I didn't test on Windows, but it seems that
the feature is very old in the upstream that we can rely on, so
let's take Jonathan's explanation and queue somethink like this.

-- >8 --
From: Johannes Schindelin <johannes.schindelin@gmx.de>
Date: Tue, 8 Feb 2011 00:17:24 -0600
Subject: [PATCH] git grep -O -i: if the pager is 'less', pass the '-I' option

When <command> happens to be the magic string "less", today

	git grep -O<command> -e<pattern>

helpfully passes +/<pattern> to less so you can navigate through
the results within a file using the n and shift+n keystrokes.

Alas, that doesn't do the right thing for a case-insensitive match,
i.e.

	git grep -i -O<command> -e<pattern>

For that case we should pass --IGNORE-CASE to "less" so that n and
shift+n can move between results ignoring case in the pattern.

The original patch came from msysgit and used "-i", but that was not
due to lack of support for "-I" but it merely overlooked that it
ought to work even when the pattern contains capital letters.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Stepan Kasal <kasal@ucw.cz>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/grep.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/builtin/grep.c b/builtin/grep.c
index 63f8603..c0573d0 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -876,6 +876,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");
+
 		if (!strcmp("less", pager) || !strcmp("vi", pager)) {
 			struct strbuf buf = STRBUF_INIT;
 			strbuf_addf(&buf, "+/%s%s",
-- 
2.0.0-rc3-419-gdb851f2

-- 
-- 
*** Please reply-to-all at all times ***
*** (do not pretend to know who is subscribed and who is not) ***
*** Please avoid top-posting. ***
The msysGit Wiki is here: https://github.com/msysgit/msysgit/wiki - Github accounts are free.

You received this message because you are subscribed to the Google
Groups "msysGit" group.
To post to this group, send email to msysgit@googlegroups.com
To unsubscribe from this group, send email to
msysgit+unsubscribe@googlegroups.com
For more options, and view previous threads, visit this group at
http://groups.google.com/group/msysgit?hl=en_US?hl=en

--- 
You received this message because you are subscribed to the Google Groups "msysGit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to msysgit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

```
