Skip to content

Commit cfb7b3b

Browse files
yoichigitster
authored andcommitted
git-jump: add an optional argument '--stdout'
It can be used with M-x grep on Emacs. Signed-off-by: Yoichi Nakayama <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a078951 commit cfb7b3b

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

contrib/git-jump/README

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ git jump grep -i foo_bar
7979
git config jump.grepCmd "ag --column"
8080
--------------------------------------------------
8181

82+
You can use the optional argument '--stdout' to print the listing to
83+
standard output instead of feeding it to the editor. You can use the
84+
argument with M-x grep on Emacs:
85+
86+
--------------------------------------------------
87+
# In Emacs, M-x grep and invoke "git jump --stdout <mode>"
88+
M-x grep<RET>git jump --stdout diff<RET>
89+
--------------------------------------------------
8290

8391
Related Programs
8492
----------------
@@ -100,7 +108,7 @@ Limitations
100108
-----------
101109

102110
This script was written and tested with vim. Given that the quickfix
103-
format is the same as what gcc produces, I expect emacs users have a
111+
format is the same as what gcc produces, I expect other tools have a
104112
similar feature for iterating through the list, but I know nothing about
105113
how to activate it.
106114

contrib/git-jump/git-jump

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
usage() {
44
cat <<\EOF
5-
usage: git jump <mode> [<args>]
5+
usage: git jump [--stdout] <mode> [<args>]
66
77
Jump to interesting elements in an editor.
88
The <mode> parameter is one of:
@@ -15,6 +15,9 @@ grep: elements are grep hits. Arguments are given to git grep or, if
1515
configured, to the command in `jump.grepCmd`.
1616
1717
ws: elements are whitespace errors. Arguments are given to diff --check.
18+
19+
If the optional argument `--stdout` is given, print the quickfix
20+
lines to standard output instead of feeding it to the editor.
1821
EOF
1922
}
2023

@@ -64,11 +67,31 @@ mode_ws() {
6467
git diff --check "$@"
6568
}
6669

70+
use_stdout=
71+
while test $# -gt 0; do
72+
case "$1" in
73+
--stdout)
74+
use_stdout=t
75+
;;
76+
--*)
77+
usage >&2
78+
exit 1
79+
;;
80+
*)
81+
break
82+
;;
83+
esac
84+
shift
85+
done
6786
if test $# -lt 1; then
6887
usage >&2
6988
exit 1
7089
fi
7190
mode=$1; shift
91+
if test "$use_stdout" = "t"; then
92+
"mode_$mode" "$@"
93+
exit 0
94+
fi
7295

7396
trap 'rm -f "$tmp"' 0 1 2 3 15
7497
tmp=`mktemp -t git-jump.XXXXXX` || exit 1

0 commit comments

Comments
 (0)