#!/bin/sh set -eu #set -x case ${GIT_EXTERNAL_DIFF-} in '') case "$0" in */*) cmd="$0" ;; *) cmd="./$0" ;; esac case ${1-} in -b|-w) XXDIFF_OPTS=$1; export XXDIFF_OPTS; shift; esac ! git diff --shortstat --exit-code "$@" || exit 0 PAGER=cat GIT_EXTERNAL_DIFF=$cmd export PAGER GIT_EXTERNAL_DIFF echo echo "***" Press Ctrl-C in this window to break all following diffs. echo echo "***" Note, you can edit the file you are diffing and then rediff echo "***" it with the original by pressing Ctrl-R on xxdiff window. echo exec git diff --ext-diff "$@" exit 1 esac die () { echo $0: "$@" >&2; sleep 2; } case ${5-} in '') die Required file argument"(s)" missing. ;; /dev/null) echo "\$2 = '$2', \$5 = '$5'" ; exit 0 ;; esac case $1 in /dev/null) echo "\$1 = '$1', \$5 = '$5'" ; exit 0 ;; esac test -f "$5" || die "'$5': Not a file." setdim () { # change tools which check current win in xinerama setup. set x `xdpyinfo | awk '/dimensions:/ {sub("x", " ", $2); print $2}'` width=`expr ${2:-1024} - 20` test $width -le 1920 || width=1900 height=`expr ${3:-768} - 200` } setdim test $width -lt 1024 && tfopt='--textfont Sans,8,-1,5,50,0,0,0,0,0' || tfopt= echo "***" Executing xxdiff ... "'$2'" "'$5'" xxdiff ${XXDIFF_OPTS-} $tfopt --geometry ${width}x${height}+5+5 "$2" "$5" || :