git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
blob babb3b5c68d87b137f1c222d3a7c12c0925fca17 1956 bytes (raw)
name: contrib/git-jump/git-jump 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
 
#!/bin/sh

usage() {
	cat <<\EOF
usage: git jump [--stdout] <mode> [<args>]

Jump to interesting elements in an editor.
The <mode> parameter is one of:

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 git grep or, if
      configured, to the command in `jump.grepCmd`.

ws: elements are whitespace errors. Arguments are given to diff --check.

If the optional argument `--stdout` is given, print the quickfix
lines to standard output instead of feeding it to the editor.
EOF
}

open_editor() {
	editor=`git var GIT_EDITOR`
	eval "$editor -q \$1"
}

mode_diff() {
	git diff --no-prefix --relative "$@" |
	perl -ne '
	if (m{^\+\+\+ (.*)}) { $file = $1; next }
	defined($file) or next;
	if (m/^@@ .*?\+(\d+)/) { $line = $1; next }
	defined($line) or next;
	if (/^ /) { $line++; next }
	if (/^[-+]\s*(.*)/) {
		print "$file:$line: $1\n";
		$line = undef;
	}
	'
}

mode_merge() {
	git ls-files -u "$@" |
	perl -pe 's/^.*?\t//' |
	sort -u |
	while IFS= read fn; do
		grep -Hn '^<<<<<<<' "$fn"
	done
}

# Grep -n generates nice quickfix-looking lines by itself,
# but let's clean up extra whitespace, so they look better if the
# editor shows them to us in the status bar.
mode_grep() {
	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 "$@"
}

use_stdout=
while test $# -gt 0; do
	case "$1" in
	--stdout)
		use_stdout=t
		shift
		;;
	--*)
		usage >&2
		exit 1
		;;
	*)
		break
		;;
	esac
done
if test $# -lt 1; then
	usage >&2
	exit 1
fi
mode=$1; shift
if test "$use_stdout" = "t"; then
	"mode_$mode" "$@"
	exit 0
fi

trap 'rm -f "$tmp"' 0 1 2 3 15
tmp=`mktemp -t git-jump.XXXXXX` || exit 1
type "mode_$mode" >/dev/null 2>&1 || { usage >&2; exit 1; }
"mode_$mode" "$@" >"$tmp"
test -s "$tmp" || exit 0
open_editor "$tmp"

debug log:

solving babb3b5c68d ...
found babb3b5c68d in https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669347422.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669261642.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669187053.git.gitgitgadget@gmail.com/ ||
	https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669126703.git.gitgitgadget@gmail.com/
found 92dbd4cde18 in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 92dbd4cde18ea18f6933ed79648a61d0c7493796	contrib/git-jump/git-jump

applying [1/1] https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669347422.git.gitgitgadget@gmail.com/
diff --git a/contrib/git-jump/git-jump b/contrib/git-jump/git-jump
index 92dbd4cde18..babb3b5c68d 100755

Checking patch contrib/git-jump/git-jump...
Applied patch contrib/git-jump/git-jump cleanly.

skipping https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669261642.git.gitgitgadget@gmail.com/ for babb3b5c68d
skipping https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669187053.git.gitgitgadget@gmail.com/ for babb3b5c68d
skipping https://public-inbox.org/git/446777d300d73498bd7da709fad75731a13d0d59.1669126703.git.gitgitgadget@gmail.com/ for babb3b5c68d
index at:
100755 babb3b5c68d87b137f1c222d3a7c12c0925fca17	contrib/git-jump/git-jump

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).