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
This commit is contained in:
Junio C Hamano 2016-08-03 15:10:27 -07:00
commit 5569c01be8
2 changed files with 11 additions and 3 deletions

View File

@ -29,7 +29,7 @@ Obviously this trivial case isn't that interesting; you could just open
`foo.c` yourself. But when you have many changes scattered across a
project, you can use the editor's support to "jump" from point to point.
Git-jump can generate three types of interesting lists:
Git-jump can generate four types of interesting lists:
1. The beginning of any diff hunks.
@ -37,6 +37,8 @@ Git-jump can generate three types of interesting lists:
3. Any grep matches.
4. Any whitespace errors detected by `git diff --check`.
Using git-jump
--------------
@ -83,7 +85,7 @@ complete list of files and line numbers for each match.
Limitations
-----------
This scripts was written and tested with vim. Given that the quickfix
This script was written and tested with vim. Given that the quickfix
format is the same as what gcc produces, I expect emacs users have a
similar feature for iterating through the list, but I know nothing about
how to activate it.

View File

@ -12,6 +12,8 @@ diff: elements are diff hunks. Arguments are given to diff.
merge: elements are merge conflicts. Arguments are ignored.
grep: elements are grep hits. Arguments are given to grep.
ws: elements are whitespace errors. Arguments are given to diff --check.
EOF
}
@ -25,7 +27,7 @@ mode_diff() {
perl -ne '
if (m{^\+\+\+ (.*)}) { $file = $1; next }
defined($file) or next;
if (m/^@@ .*\+(\d+)/) { $line = $1; next }
if (m/^@@ .*?\+(\d+)/) { $line = $1; next }
defined($line) or next;
if (/^ /) { $line++; next }
if (/^[-+]\s*(.*)/) {
@ -55,6 +57,10 @@ mode_grep() {
'
}
mode_ws() {
git diff --check "$@"
}
if test $# -lt 1; then
usage >&2
exit 1