contrib/git-jump/git-jump: jump to exact location

Take advantage of 'git-grep(1)''s new option, '--column' in order to teach Peff's 'git-jump' script how to jump to the correct column for any given match. 'git-grep(1)''s output is in the correct format for Vim's jump list, so no additional cleanup is necessary. Signed-off-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Taylor Blau committed Jun 22, 2018 at 10:49 UTC 240cf2a25744b45c514fe850363721615a1c4b8c
2 files changed +11 -3
contrib/git-jump/README
+10 -2
@@ -25,6 +25,13 @@ git-jump will feed this to the editor:
25 foo.c:2: printf("hello word!\n");
26 -----------------------------------
27
28 +Or, when running 'git jump grep', column numbers will also be emitted,
29 +e.g. `git jump grep "hello"` would return:
30 +
31 +-----------------------------------
32 +foo.c:2:9: printf("hello word!\n");
33 +-----------------------------------
34 +
35 Obviously this trivial case isn't that interesting; you could just open
36 `foo.c` yourself. But when you have many changes scattered across a
37 project, you can use the editor's support to "jump" from point to point.
@@ -35,7 +42,8 @@ Git-jump can generate four types of interesting lists:
42
43 2. The beginning of any merge conflict markers.
44
38 - 3. Any grep matches.
45 + 3. Any grep matches, including the column of the first match on a
46 + line.
47
48 4. Any whitespace errors detected by `git diff --check`.
49
@@ -82,7 +90,7 @@ which does something similar to `git jump grep`. However, it is limited
90 to positioning the cursor to the correct line in only the first file,
91 leaving you to locate subsequent hits in that file or other files using
92 the editor or pager. By contrast, git-jump provides the editor with a
85 -complete list of files and line numbers for each match.
93 +complete list of files, lines, and a column number for each match.
94
95
96 Limitations
contrib/git-jump/git-jump
+1 -1
@@ -52,7 +52,7 @@ mode_merge() {
52 # editor shows them to us in the status bar.
53 mode_grep() {
54 cmd=$(git config jump.grepCmd)
55 - test -n "$cmd" || cmd="git grep -n"
55 + test -n "$cmd" || cmd="git grep -n --column"
56 $cmd "$@" |
57 perl -pe '
58 s/[ \t]+/ /g;