diff options
author | Yoichi Nakayama <yoichi.nakayama@gmail.com> | 2022-11-27 04:18:51 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-11-27 04:49:51 +0300 |
commit | cfb7b3b39183e9711340ee464e58199f44e0de4e (patch) | |
tree | 44ee059855f4d06f58a5cf3b14dfcea737e0fb5d /contrib | |
parent | a0789512c5a4ae7da935cd2e419f253cb3cb4ce7 (diff) |
git-jump: add an optional argument '--stdout'
It can be used with M-x grep on Emacs.
Signed-off-by: Yoichi Nakayama <yoichi.nakayama@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/git-jump/README | 10 | ||||
-rwxr-xr-x | contrib/git-jump/git-jump | 25 |
2 files changed, 33 insertions, 2 deletions
diff --git a/contrib/git-jump/README b/contrib/git-jump/README index 8bcace29d2..3211841305 100644 --- a/contrib/git-jump/README +++ b/contrib/git-jump/README @@ -79,6 +79,14 @@ 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 instead of feeding it to the editor. You can use the +argument with M-x grep on Emacs: + +-------------------------------------------------- +# In Emacs, M-x grep and invoke "git jump --stdout <mode>" +M-x grep<RET>git jump --stdout diff<RET> +-------------------------------------------------- Related Programs ---------------- @@ -100,7 +108,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 92dbd4cde1..be0642bbe3 100755 --- a/contrib/git-jump/git-jump +++ b/contrib/git-jump/git-jump @@ -2,7 +2,7 @@ usage() { cat <<\EOF -usage: git jump <mode> [<args>] +usage: git jump [--stdout] <mode> [<args>] Jump to interesting elements in an editor. The <mode> 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 instead of feeding it to the editor. EOF } @@ -64,11 +67,31 @@ mode_ws() { git diff --check "$@" } +use_stdout= +while test $# -gt 0; do + case "$1" in + --stdout) + use_stdout=t + ;; + --*) + usage >&2 + exit 1 + ;; + *) + break + ;; + esac + shift +done if test $# -lt 1; then usage >&2 exit 1 fi mode=$1; shift +if test "$use_stdout" = "t"; then + "mode_$mode" "$@" + exit 0 +fi trap 'rm -f "$tmp"' 0 1 2 3 15 tmp=`mktemp -t git-jump.XXXXXX` || exit 1 |