]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/sh | |
2 | ||
3 | set -e | |
4 | ||
5 | SCRIPT="$(readlink -f "$0")" | |
6 | TARGET="${SCRIPT}.real" | |
7 | ||
8 | main() { | |
9 | # Some (old?) versions of git provided the compiled script. | |
10 | d="/usr/share/doc/git/contrib/diff-highlight" | |
11 | if [ -x "${d}/diff-highlight" ] ; then | |
12 | exec "${d}/diff-highlight" | |
13 | fi | |
14 | ||
15 | # See if we need to bootstrap first. | |
16 | if [ ! -x "${TARGET}" ] && [ -e "${d}" ] ; then | |
17 | ( | |
18 | echo "#!/usr/bin/env perl" | |
19 | cat "${d}/DiffHighlight.pm" "${d}/diff-highlight.perl" | |
20 | ) >"${TARGET}" | |
21 | chmod a+rx "${TARGET}" | |
22 | fi | |
23 | ||
24 | # If we've already bootstrapped, use it. | |
25 | if [ -x "${TARGET}" ] ; then | |
26 | exec "${TARGET}" "$@" | |
27 | elif [ -x "/usr/bin/diff-highlight" ] ; then | |
28 | exec /usr/bin/diff-highlight "$@" | |
29 | else | |
30 | # Fallback so .gitconfig setings always work. | |
31 | exec cat | |
32 | fi | |
33 | } | |
34 | ||
35 | main "$@" |