]> git.wh0rd.org - home.git/commitdiff
diff-highlight: handle newer git versions
authorMike Frysinger <vapier@gentoo.org>
Tue, 10 Nov 2020 08:50:45 +0000 (03:50 -0500)
committerMike Frysinger <vapier@gentoo.org>
Tue, 10 Nov 2020 08:56:49 +0000 (03:56 -0500)
It seems git has stopped providing this tool precompiled, so we have
to build it up ourselves.

.bin/diff-highlight [new file with mode: 0755]
.gitignore

diff --git a/.bin/diff-highlight b/.bin/diff-highlight
new file mode 100755 (executable)
index 0000000..940d802
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -e
+
+SCRIPT="$(readlink -f "$0")"
+TARGET="${SCRIPT}.real"
+
+main() {
+       # Some (old?) versions of git provided the compiled script.
+       d="/usr/share/doc/git/contrib/diff-highlight"
+       if [ -x "${d}/diff-highlight" ] ; then
+               exec "${d}/diff-highlight"
+       fi
+
+       # See if we need to bootstrap first.
+       if [ ! -x "${TARGET}" ] && [ -e "${d}" ] ; then
+               (
+               echo "#!/usr/bin/env perl"
+               cat "${d}/DiffHighlight.pm" "${d}/diff-highlight.perl"
+               ) >"${TARGET}"
+               chmod a+rx "${TARGET}"
+       fi
+
+       # If we've already bootstrapped, use it.
+       if [ -x "${TARGET}" ] ; then
+               exec "${TARGET}" "$@"
+       else
+               # Fallback so .gitconfig setings always work.
+               exec cat
+       fi
+}
+
+main "$@"
index 7f95ddf19c148ed12fc741ea74dfb9a7f48a9ae8..df28d590a5e64425f8253bda10dec7df91b61c6a 100644 (file)
@@ -412,7 +412,9 @@ lock
 
 # per-system files
 /.asoundrc
+/.bin/diff-highlight.real
 /.bin/gsutil
+/.bin/repo*
 /.boto*
 /.chrome-remote-desktop-session
 /.forward