5 usage: git jump <mode> [<args>]
7 Jump to interesting elements in an editor.
8 The <mode> parameter is one of:
10 diff: elements are diff hunks. Arguments are given to diff.
12 merge: elements are merge conflicts. Arguments are ignored.
14 grep: elements are grep hits. Arguments are given to git grep or, if
15 configured, to the command in `jump.grepCmd`.
17 ws: elements are whitespace errors. Arguments are given to diff --check.
22 editor=`git var GIT_EDITOR`
27 git diff --no-prefix --relative "$@" |
29 if (m{^\+\+\+ (.*)}) { $file = $1; next }
30 defined($file) or next;
31 if (m/^@@ .*?\+(\d+)/) { $line = $1; next }
32 defined($line) or next;
33 if (/^ /) { $line++; next }
35 print "$file:$line: $1\n";
43 perl -pe 's/^.*?\t//' |
45 while IFS= read fn; do
46 grep -Hn '^<<<<<<<' "$fn"
50 # Grep -n generates nice quickfix-looking lines by itself,
51 # but let's clean up extra whitespace, so they look better if the
52 # editor shows them to us in the status bar.
54 cmd=$(git config jump.grepCmd)
55 test -n "$cmd" || cmd="git grep -n --column"
67 if test $# -lt 1; then
73 trap 'rm -f "$tmp"' 0 1 2 3 15
74 tmp=`mktemp -t git-jump.XXXXXX` || exit 1
75 type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
76 "mode_$mode" "$@" >"$tmp"
77 test -s "$tmp" || exit 0