git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] contrib/git-jump: allow to configure the grep command
@ 2017-11-09 20:30 Beat Bolli
  0 siblings, 0 replies; 7+ messages in thread
From: Beat Bolli @ 2017-11-09 20:30 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Add the configuration option "jump.grepCmd" that allows to configure the
command that is used to search in grep mode. This allows the users of
git-jump to use ag(1) or ack(1) as search engines.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/git-jump/README   | 3 +++
 contrib/git-jump/git-jump | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/contrib/git-jump/README b/contrib/git-jump/README
index 225e3f095..9f58d5db8 100644
--- a/contrib/git-jump/README
+++ b/contrib/git-jump/README
@@ -63,6 +63,9 @@ git jump grep foo_bar
 # same as above, but case-insensitive; you can give
 # arbitrary grep options
 git jump grep -i foo_bar
+
+# use the silver searcher for git jump grep
+git config jump.grepCmd "ag --column"
 --------------------------------------------------
 
 
diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 427f206a4..80ab0590b 100755
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.
 
 merge: elements are merge conflicts. Arguments are ignored.
 
-grep: elements are grep hits. Arguments are given to grep.
+grep: elements are grep hits. Arguments are given to git grep or, if
+      configured, to the command in `jump.grepCmd`.
 
 ws: elements are whitespace errors. Arguments are given to diff --check.
 EOF
@@ -50,7 +51,9 @@ mode_merge() {
 # but let's clean up extra whitespace, so they look better if the
 # editor shows them to us in the status bar.
 mode_grep() {
-	git grep -n "$@" |
+	cmd=$(git config jump.grepCmd)
+	test -n "$cmd" || cmd="git grep -n"
+	$cmd "$@" |
 	perl -pe '
 	s/[ \t]+/ /g;
 	s/^ *//;
-- 
2.15.0.rc1.299.gda03b47c3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH] contrib/git-jump: allow to configure the grep command
@ 2017-11-19 23:05 Beat Bolli
  2017-11-20  3:11 ` Junio C Hamano
  2017-11-20 19:20 ` Jeff King
  0 siblings, 2 replies; 7+ messages in thread
From: Beat Bolli @ 2017-11-19 23:05 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Beat Bolli

Add the configuration option "jump.grepCmd" that allows to configure the
command that is used to search in grep mode. This allows the users of
git-jump to use ag(1) or ack(1) as search engines.

Signed-off-by: Beat Bolli <dev+git@drbeat.li>
---
 contrib/git-jump/README   | 3 +++
 contrib/git-jump/git-jump | 7 +++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/contrib/git-jump/README b/contrib/git-jump/README
index 225e3f095..9f58d5db8 100644
--- a/contrib/git-jump/README
+++ b/contrib/git-jump/README
@@ -63,6 +63,9 @@ git jump grep foo_bar
 # same as above, but case-insensitive; you can give
 # arbitrary grep options
 git jump grep -i foo_bar
+
+# use the silver searcher for git jump grep
+git config jump.grepCmd "ag --column"
 --------------------------------------------------
 
 
diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 427f206a4..80ab0590b 100755
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.
 
 merge: elements are merge conflicts. Arguments are ignored.
 
-grep: elements are grep hits. Arguments are given to grep.
+grep: elements are grep hits. Arguments are given to git grep or, if
+      configured, to the command in `jump.grepCmd`.
 
 ws: elements are whitespace errors. Arguments are given to diff --check.
 EOF
@@ -50,7 +51,9 @@ mode_merge() {
 # but let's clean up extra whitespace, so they look better if the
 # editor shows them to us in the status bar.
 mode_grep() {
-	git grep -n "$@" |
+	cmd=$(git config jump.grepCmd)
+	test -n "$cmd" || cmd="git grep -n"
+	$cmd "$@" |
 	perl -pe '
 	s/[ \t]+/ /g;
 	s/^ *//;
-- 
2.15.0.rc1.299.gda03b47c3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib/git-jump: allow to configure the grep command
  2017-11-19 23:05 [PATCH] contrib/git-jump: allow to configure the grep command Beat Bolli
@ 2017-11-20  3:11 ` Junio C Hamano
  2017-11-20 19:18   ` Jeff King
  2017-11-20 19:20 ` Jeff King
  1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2017-11-20  3:11 UTC (permalink / raw)
  To: Jeff King, Beat Bolli; +Cc: git

Beat Bolli <dev+git@drbeat.li> writes:

> Add the configuration option "jump.grepCmd" that allows to configure the
> command that is used to search in grep mode. This allows the users of
> git-jump to use ag(1) or ack(1) as search engines.
>
> Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> ---

Thanks.  The contrib/README file has this to say (also read the
surrounding text):

    ... If
    you have patches to things in contrib/ area, the patch should be
    first sent to the primary author, and then the primary author
    should ack and forward it to me (git pull request is nicer).

Peff, I think we need a clear indication in contrib/git-jump/README
to whom patches to the area should be sent.  I know how to run 

    $ git shortlog -n --no-merges contrib/git-jump

but not everybody does (or bothers).

>  contrib/git-jump/README   | 3 +++
>  contrib/git-jump/git-jump | 7 +++++--
>  2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/contrib/git-jump/README b/contrib/git-jump/README
> index 225e3f095..9f58d5db8 100644
> --- a/contrib/git-jump/README
> +++ b/contrib/git-jump/README
> @@ -63,6 +63,9 @@ git jump grep foo_bar
>  # same as above, but case-insensitive; you can give
>  # arbitrary grep options
>  git jump grep -i foo_bar
> +
> +# use the silver searcher for git jump grep
> +git config jump.grepCmd "ag --column"
>  --------------------------------------------------
>  
>  
> diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
> index 427f206a4..80ab0590b 100755
> --- a/contrib/git-jump/git-jump
> +++ b/contrib/git-jump/git-jump
> @@ -11,7 +11,8 @@ diff: elements are diff hunks. Arguments are given to diff.
>  
>  merge: elements are merge conflicts. Arguments are ignored.
>  
> -grep: elements are grep hits. Arguments are given to grep.
> +grep: elements are grep hits. Arguments are given to git grep or, if
> +      configured, to the command in `jump.grepCmd`.
>  
>  ws: elements are whitespace errors. Arguments are given to diff --check.
>  EOF
> @@ -50,7 +51,9 @@ mode_merge() {
>  # but let's clean up extra whitespace, so they look better if the
>  # editor shows them to us in the status bar.
>  mode_grep() {
> -	git grep -n "$@" |
> +	cmd=$(git config jump.grepCmd)
> +	test -n "$cmd" || cmd="git grep -n"
> +	$cmd "$@" |
>  	perl -pe '
>  	s/[ \t]+/ /g;
>  	s/^ *//;

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib/git-jump: allow to configure the grep command
  2017-11-20  3:11 ` Junio C Hamano
@ 2017-11-20 19:18   ` Jeff King
  2017-11-20 19:55     ` Jonathan Nieder
  2017-11-21  1:58     ` Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: Jeff King @ 2017-11-20 19:18 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Beat Bolli, git

On Mon, Nov 20, 2017 at 12:11:13PM +0900, Junio C Hamano wrote:

> Beat Bolli <dev+git@drbeat.li> writes:
> 
> > Add the configuration option "jump.grepCmd" that allows to configure the
> > command that is used to search in grep mode. This allows the users of
> > git-jump to use ag(1) or ack(1) as search engines.
> >
> > Signed-off-by: Beat Bolli <dev+git@drbeat.li>
> > ---
> 
> Thanks.  The contrib/README file has this to say (also read the
> surrounding text):
> 
>     ... If
>     you have patches to things in contrib/ area, the patch should be
>     first sent to the primary author, and then the primary author
>     should ack and forward it to me (git pull request is nicer).

I'm not sure the "ack and forward" and "pull request" bits necessarily
make sense here, as I do not host git-jump as a separate repository.
I'd expect people to send to the list and cc me, and you'd pick it up as
long as I'd ack'd it.

But I'm happy to revisit that if you prefer to do it a different way. We
could even pull it out of contrib/ entirely and I could just host it as
a separate project entirely.

> Peff, I think we need a clear indication in contrib/git-jump/README
> to whom patches to the area should be sent.  I know how to run 
> 
>     $ git shortlog -n --no-merges contrib/git-jump
> 
> but not everybody does (or bothers).

How about this?

-- >8 --
Subject: [PATCH] git-jump: give contact instructions in the README

Let's make it clear how patches should flow into
contrib/git-jump. The normal Git maintainer does not
necessarily care about things in contrib/, and authors of
individual components should be the ones giving the final
review/ack for a patch. Ditto for bug reports, which are
likely to get more attention from the area expert.

Signed-off-by: Jeff King <peff@peff.net>
---
 contrib/git-jump/README | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/contrib/git-jump/README b/contrib/git-jump/README
index 225e3f0954..4257cef2e6 100644
--- a/contrib/git-jump/README
+++ b/contrib/git-jump/README
@@ -92,3 +92,10 @@ how to activate it.
 
 The shell snippets to generate the quickfix lines will almost certainly
 choke on filenames with exotic characters (like newlines).
+
+Contributing
+------------
+
+Bug fixes, bug reports, and feature requests should be discussed on the
+Git mailing list <git@vger.kernel.org>, and cc'd to the git-jump
+maintainer, Jeff King <peff@peff.net>.
-- 
2.15.0.494.g79a8547723

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib/git-jump: allow to configure the grep command
  2017-11-19 23:05 [PATCH] contrib/git-jump: allow to configure the grep command Beat Bolli
  2017-11-20  3:11 ` Junio C Hamano
@ 2017-11-20 19:20 ` Jeff King
  1 sibling, 0 replies; 7+ messages in thread
From: Jeff King @ 2017-11-20 19:20 UTC (permalink / raw)
  To: Beat Bolli; +Cc: git, Junio C Hamano

On Mon, Nov 20, 2017 at 12:05:36AM +0100, Beat Bolli wrote:

> Add the configuration option "jump.grepCmd" that allows to configure the
> command that is used to search in grep mode. This allows the users of
> git-jump to use ag(1) or ack(1) as search engines.

This patch looks good to me. The user needs to be careful to use some
option that shows the line number, but that's hopefully obvious from
your example.

> +# use the silver searcher for git jump grep
> +git config jump.grepCmd "ag --column"

I wondered what "vim -q" would do with the --column output. Quite
nicely, it puts the cursor right where you'd want it to be. I'm tempted
to teach "git grep" the same option. ;)

-Peff

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib/git-jump: allow to configure the grep command
  2017-11-20 19:18   ` Jeff King
@ 2017-11-20 19:55     ` Jonathan Nieder
  2017-11-21  1:58     ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Jonathan Nieder @ 2017-11-20 19:55 UTC (permalink / raw)
  To: Jeff King; +Cc: Junio C Hamano, Beat Bolli, git

Jeff King wrote:

> Subject: [PATCH] git-jump: give contact instructions in the README
>
> Let's make it clear how patches should flow into
> contrib/git-jump. The normal Git maintainer does not
> necessarily care about things in contrib/, and authors of
> individual components should be the ones giving the final
> review/ack for a patch. Ditto for bug reports, which are
> likely to get more attention from the area expert.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  contrib/git-jump/README | 7 +++++++
>  1 file changed, 7 insertions(+)

Thanks for making it clearer.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

> diff --git a/contrib/git-jump/README b/contrib/git-jump/README
> index 225e3f0954..4257cef2e6 100644
> --- a/contrib/git-jump/README
> +++ b/contrib/git-jump/README
> @@ -92,3 +92,10 @@ how to activate it.
>  
>  The shell snippets to generate the quickfix lines will almost certainly
>  choke on filenames with exotic characters (like newlines).
> +
> +Contributing
> +------------
> +
> +Bug fixes, bug reports, and feature requests should be discussed on the
> +Git mailing list <git@vger.kernel.org>, and cc'd to the git-jump
> +maintainer, Jeff King <peff@peff.net>.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] contrib/git-jump: allow to configure the grep command
  2017-11-20 19:18   ` Jeff King
  2017-11-20 19:55     ` Jonathan Nieder
@ 2017-11-21  1:58     ` Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2017-11-21  1:58 UTC (permalink / raw)
  To: Jeff King; +Cc: Beat Bolli, git

Jeff King <peff@peff.net> writes:

> How about this?
>
> -- >8 --
> Subject: [PATCH] git-jump: give contact instructions in the README
>
> Let's make it clear how patches should flow into
> contrib/git-jump. The normal Git maintainer does not
> necessarily care about things in contrib/, and authors of
> individual components should be the ones giving the final
> review/ack for a patch. Ditto for bug reports, which are
> likely to get more attention from the area expert.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
>  contrib/git-jump/README | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/contrib/git-jump/README b/contrib/git-jump/README
> index 225e3f0954..4257cef2e6 100644
> --- a/contrib/git-jump/README
> +++ b/contrib/git-jump/README
> @@ -92,3 +92,10 @@ how to activate it.
>  
>  The shell snippets to generate the quickfix lines will almost certainly
>  choke on filenames with exotic characters (like newlines).
> +
> +Contributing
> +------------
> +
> +Bug fixes, bug reports, and feature requests should be discussed on the
> +Git mailing list <git@vger.kernel.org>, and cc'd to the git-jump
> +maintainer, Jeff King <peff@peff.net>.

Thanks, will queue.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-11-21  1:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-19 23:05 [PATCH] contrib/git-jump: allow to configure the grep command Beat Bolli
2017-11-20  3:11 ` Junio C Hamano
2017-11-20 19:18   ` Jeff King
2017-11-20 19:55     ` Jonathan Nieder
2017-11-21  1:58     ` Junio C Hamano
2017-11-20 19:20 ` Jeff King
  -- strict thread matches above, loose matches on Subject: below --
2017-11-09 20:30 Beat Bolli

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).