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

2014-05-15 Thread Johannes Schindelin
Hi Junio,

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

 Jonathan Nieder jrnie...@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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-15 Thread Johannes Schindelin
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.
   * -epattern1 --or -epattern2
  
  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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-15 Thread Jonathan Nieder
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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-15 Thread Jonathan Nieder
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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-15 Thread Johannes Schindelin
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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-15 Thread Jeff King
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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-15 Thread Junio C Hamano
Johannes Schindelin johannes.schinde...@gmx.de writes:

 Jonathan Nieder jrnie...@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.schinde...@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 -Ocommand -epattern

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 -Ocommand -epattern

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.schinde...@gmx.de
Signed-off-by: Stepan Kasal ka...@ucw.cz
Helped-by: Jonathan Nieder jrnie...@gmail.com
Signed-off-by: Junio C Hamano gits...@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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-14 Thread Junio C Hamano
Stepan Kasal ka...@ucw.cz writes:

 From: Johannes Schindelin johannes.schinde...@gmx.de
 Date: Tue, 8 Feb 2011 00:17:24 -0600

 Signed-off-by: Johannes Schindelin johannes.schinde...@gmx.de
 Signed-off-by: Stepan Kasal ka...@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

 -- 
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-14 Thread Matthieu Moy
Junio C Hamano gits...@pobox.com writes:

 Stepan Kasal ka...@ucw.cz writes:

 From: Johannes Schindelin johannes.schinde...@gmx.de
 Date: Tue, 8 Feb 2011 00:17:24 -0600

 Signed-off-by: Johannes Schindelin johannes.schinde...@gmx.de
 Signed-off-by: Stepan Kasal ka...@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/
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-14 Thread Jonathan Nieder
Hi,

Junio C Hamano wrote:
 Stepan Kasal ka...@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 -Ocommand -epattern

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.
 * -epattern1 --or -epattern2

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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-14 Thread Stepan Kasal
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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-14 Thread Junio C Hamano
Jonathan Nieder jrnie...@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.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

2014-05-14 Thread Jeff King
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.
  * -epattern1 --or -epattern2
 
 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
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html