#!/bin/sh

merge_ts() {
    stat -f "%m" "$MERGED"
}

GF_MTIME_START=$(merge_ts)

GF_APP_PATH="/Applications/Beyond Compare.app"
if [ ! -d "$GF_APP_PATH" ]; then
    GF_APP_PATH="$HOME/Applications/Beyond Compare.app"
fi

"$GF_APP_PATH/Contents/MacOS/bcomp" \
    -ro1 -ro2 \
    -title1="Local - $LOCAL" \
    -title2="Remote - $REMOTE" \
    -title3="Base - $BASE" \
    "$LOCAL" "$REMOTE" "$BASE" "$MERGED"

GF_MTIME_END=$(merge_ts)

if [ $GF_MTIME_END -gt $GF_MTIME_START ]; then
    exit 0
fi

exit 1
