contrib/git-jump: add whitespace-checking mode
If you have whitespace errors in lines you've introduced, it can be convenient to be able to jump directly to them for fixing. You can't quite use "git jump diff" for this, because though it passes arbitrary options to "git diff", it expects to see an actual unified diff in the output. Whereas "git diff --check" actually produces lines that look like compiler quickfix lines already, meaning we just need to run it and feed the output directly to the editor. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jul 22, 2016 at 12:35 UTC
1af9c6096a7ec6cba3a5f7d359cb1caf2152496a
2 files changed
+9
-1
contrib/git-jump/README
+3
-1
@@ -29,7 +29,7 @@ Obviously this trivial case isn't that interesting; you could just open
29
`foo.c` yourself. But when you have many changes scattered across a
30
project, you can use the editor's support to "jump" from point to point.
31
32
-Git-jump can generate three types of interesting lists:
32
+Git-jump can generate four types of interesting lists:
33
34
1. The beginning of any diff hunks.
35
@@ -37,6 +37,8 @@ Git-jump can generate three types of interesting lists:
37
38
3. Any grep matches.
39
40
+ 4. Any whitespace errors detected by `git diff --check`.
41
+
42
43
Using git-jump
44
--------------
contrib/git-jump/git-jump
+6
@@ -12,6 +12,8 @@ diff: elements are diff hunks. Arguments are given to diff.
12
merge: elements are merge conflicts. Arguments are ignored.
13
14
grep: elements are grep hits. Arguments are given to grep.
15
+
16
+ws: elements are whitespace errors. Arguments are given to diff --check.
17
EOF
18
}
19
@@ -55,6 +57,10 @@ mode_grep() {
57
'
58
}
59
60
+mode_ws() {
61
+ git diff --check "$@"
62
+}
63
+
64
if test $# -lt 1; then
65
usage >&2
66
exit 1