summaryrefslogtreecommitdiff
path: root/contrib/git-jump/git-jump
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/git-jump/git-jump')
-rwxr-xr-xcontrib/git-jump/git-jump15
1 files changed, 12 insertions, 3 deletions
diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index dc90cd6..931b0fe 100755
--- a/contrib/git-jump/git-jump
+++ b/contrib/git-jump/git-jump
@@ -11,7 +11,10 @@ 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.
+grep: elements are grep hits. Arguments are given to git grep or, if
+ configured, to the command in `jump.grepCmd`.
+
+ws: elements are whitespace errors. Arguments are given to diff --check.
EOF
}
@@ -25,7 +28,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*(.*)/) {
@@ -48,13 +51,19 @@ mode_merge() {
# but let's clean up extra whitespace, so they look better if the
# editor shows them to us in the status bar.
mode_grep() {
- git grep -n "$@" |
+ cmd=$(git config jump.grepCmd)
+ test -n "$cmd" || cmd="git grep -n --column"
+ $cmd "$@" |
perl -pe '
s/[ \t]+/ /g;
s/^ *//;
'
}
+mode_ws() {
+ git diff --check "$@"
+}
+
if test $# -lt 1; then
usage >&2
exit 1