Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 64 lines (55 sloc) 1.31 KB
#!/bin/sh
#
# Wrapper script to use FileMerge as a merge-tool-cmd in Subversion
#
FM="$(which filemerge)"
FMDIFF="$(basename $0)"
GN="/usr/local/bin/growlnotify"
# Resolve symlinks leading to FileMerge
while [ -L "$FM" ]; do
FM_DIR="$(dirname "$FM")"
FM="$(readlink "$FM")"
[[ $FM == /* ]] || FM="$FM_DIR/$FM"
done
while [ $# != 0 ]; do
case $1 in
-*)
echo "Unknown option: $1" 1>&2
exit 1
;;
*)
if [ -z "$ancestorfile" ]; then
ancestorfile="$1"
elif [ -z "$leftfile" ]; then
leftfile="$1"
elif [ -z "$rightfile" ]; then
rightfile="$1"
elif [ -z "$mergefile" ]; then
mergefile="$1"
elif [ -z "$wcpath" ]; then
wcpath="$1"
else
echo "Too many files to start merge" 1>&2
exit 2
fi
esac
shift
done
if [ -z "$ancestorfile" ] || [ -z "$leftfile" ] ||
[ -z "$rightfile" ] || [ -z "$mergefile" ]; then
echo "Usage: $0 [options] oldfile yourfile myfile outputfile" 1>&2
exit 2
fi
echo Starting FileMerge... 1>&2
[ -x "$GN" ] && "$GN" -a FileMerge -n "$FMDIFF" -m "$mergefile" "Starting FileMerge"
[[ "$mergefile" == */* ]] || mergefile="./$mergefile"
tempfile=`mktemp -t $FMDIFF`
"$FM" -left "$leftfile" -right "$rightfile" \
-ancestor "$ancestorfile" -merge "$mergefile"
if [ "$mergefile" -nt "$tempfile" ]; then
rm "$tempfile"
exit 0
else
rm "$tempfile"
exit 1
fi