Skip to content

Commit 5569c01

Browse files
committed
Merge branch 'jk/git-jump'
"git jump" script (in contrib/) has been updated a bit. * jk/git-jump: contrib/git-jump: fix typo in README contrib/git-jump: add whitespace-checking mode contrib/git-jump: fix greedy regex when matching hunks
2 parents 5a2f4d3 + a91e692 commit 5569c01

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

contrib/git-jump/README

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ Obviously this trivial case isn't that interesting; you could just open
2929
`foo.c` yourself. But when you have many changes scattered across a
3030
project, you can use the editor's support to "jump" from point to point.
3131

32-
Git-jump can generate three types of interesting lists:
32+
Git-jump can generate four types of interesting lists:
3333

3434
1. The beginning of any diff hunks.
3535

3636
2. The beginning of any merge conflict markers.
3737

3838
3. Any grep matches.
3939

40+
4. Any whitespace errors detected by `git diff --check`.
41+
4042

4143
Using git-jump
4244
--------------
@@ -83,7 +85,7 @@ complete list of files and line numbers for each match.
8385
Limitations
8486
-----------
8587

86-
This scripts was written and tested with vim. Given that the quickfix
88+
This script was written and tested with vim. Given that the quickfix
8789
format is the same as what gcc produces, I expect emacs users have a
8890
similar feature for iterating through the list, but I know nothing about
8991
how to activate it.

contrib/git-jump/git-jump

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ diff: elements are diff hunks. Arguments are given to diff.
1212
merge: elements are merge conflicts. Arguments are ignored.
1313
1414
grep: elements are grep hits. Arguments are given to grep.
15+
16+
ws: elements are whitespace errors. Arguments are given to diff --check.
1517
EOF
1618
}
1719

@@ -25,7 +27,7 @@ mode_diff() {
2527
perl -ne '
2628
if (m{^\+\+\+ (.*)}) { $file = $1; next }
2729
defined($file) or next;
28-
if (m/^@@ .*\+(\d+)/) { $line = $1; next }
30+
if (m/^@@ .*?\+(\d+)/) { $line = $1; next }
2931
defined($line) or next;
3032
if (/^ /) { $line++; next }
3133
if (/^[-+]\s*(.*)/) {
@@ -55,6 +57,10 @@ mode_grep() {
5557
'
5658
}
5759

60+
mode_ws() {
61+
git diff --check "$@"
62+
}
63+
5864
if test $# -lt 1; then
5965
usage >&2
6066
exit 1

0 commit comments

Comments
 (0)