From: Yoichi Nakayama via GitGitGadget Date: Sat, 19 Nov 2022 14:02:19 GMT Subject: [PATCH 1/2] git-jump: add an optional argument 'stdout' Message-ID: In-Reply-To: From: Yoichi Nakayama It can be used with M-x grep on Emacs. Signed-off-by: Yoichi Nakayama --- contrib/git-jump/README | 9 ++++++++- contrib/git-jump/git-jump | 11 ++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/contrib/git-jump/README b/contrib/git-jump/README index 8bcace29d21..6aaa6a928d2 100644 --- a/contrib/git-jump/README +++ b/contrib/git-jump/README @@ -79,6 +79,13 @@ git jump grep -i foo_bar git config jump.grepCmd "ag --column" -------------------------------------------------- +You can use the optional argument 'stdout' to print the listing to +standard output. You can use it with M-x grep on Emacs. + +-------------------------------------------------- +# In Emacs, M-x grep and invoke "git jump stdout " +Run grep (like this): git jump stdout diff +-------------------------------------------------- Related Programs ---------------- @@ -100,7 +107,7 @@ Limitations ----------- This script was written and tested with vim. Given that the quickfix -format is the same as what gcc produces, I expect emacs users have a +format is the same as what gcc produces, I expect other tools have a similar feature for iterating through the list, but I know nothing about how to activate it. diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump index 92dbd4cde18..a907f69304d 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -2,7 +2,7 @@ usage() { cat <<\EOF -usage: git jump [] +usage: git jump [stdout] [] Jump to interesting elements in an editor. The parameter is one of: @@ -15,6 +15,9 @@ 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. + +If the optional argument `stdout` is given, print the quickfix +lines to standard output. EOF } @@ -69,6 +72,12 @@ if test $# -lt 1; then exit 1 fi mode=$1; shift +if test "$mode" = "stdout"; then + mode=$1; shift + type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; } + "mode_$mode" "$@" 2>/dev/null + exit 0 +fi trap 'rm -f "$tmp"' 0 1 2 3 15 tmp=`mktemp -t git-jump.XXXXXX` || exit 1 -- gitgitgadget