help: add --config to list all available config
[gitweb.git] / contrib / git-jump / git-jump
index a33674e47a669e45f257a92aaffad8002d190c5d..80ab0590bc92221e2b2f8f35b76f5a0cbb970f8b 100755 (executable)
@@ -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
 }
 
@@ -21,11 +24,11 @@ open_editor() {
 }
 
 mode_diff() {
-       git diff --relative "$@" |
+       git diff --no-prefix --relative "$@" |
        perl -ne '
-       if (m{^\+\+\+ b/(.*)}) { $file = $1; next }
+       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"
+       $cmd "$@" |
        perl -pe '
        s/[ \t]+/ /g;
        s/^ *//;
        '
 }
 
+mode_ws() {
+       git diff --check "$@"
+}
+
 if test $# -lt 1; then
        usage >&2
        exit 1