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 grep.
19 editor=`git var GIT_EDITOR`
24 git diff --no-prefix --relative "$@" |
26 if (m{^\+\+\+ (.*)}) { $file = $1; next }
27 defined($file) or next;
28 if (m/^@@ .*\+(\d+)/) { $line = $1; next }
29 defined($line) or next;
30 if (/^ /) { $line++; next }
32 print "$file:$line: $1\n";
40 perl -pe 's/^.*?\t//' |
42 while IFS= read fn; do
43 grep -Hn '^<<<<<<<' "$fn"
47 # Grep -n generates nice quickfix-looking lines by itself,
48 # but let's clean up extra whitespace, so they look better if the
49 # editor shows them to us in the status bar.
58 if test $# -lt 1; then
64 trap 'rm -f "$tmp"' 0 1 2 3 15
65 tmp=`mktemp -t git-jump.XXXXXX` || exit 1
66 type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
67 "mode_$mode" "$@" >"$tmp"
68 test -s "$tmp" || exit 0