#!/bin/bash # When running git mergetool with the mergetool.bc3.cmd option selected and it # is set to run beyondcompare-merge-altbin.sh, then if that script detects # that either the "local" (left) or "remote" (right) file is not a text file, # then that script invokes this script in place of Beyond Compare. # See http://www.scootersoftware.com/vbulletin/showthread.php?14310-git-conflicts-with-binary-files&p=49048 for the reason. # git config --global mergetool.bc3.cmd "beyondcompare-merge-altbin.sh \"\$LOCAL\" \"\$REMOTE\" \"\$BASE\" \"\$MERGED\"" # Arguments are the same as for beyondcompare, except that no flags are needed # and paths are Cywin rather than Windows: # local remote base merged # Note that base is not really needed as we just copy left or right to merged local="$1" remote="$2" base="$3" merged="$4" simple="`echo "$local" | sed -e 's/^\(.*\)\.[^.]*\.[^.]*\.[^.]*$/\1/'`" echo "--->'$simple' not a text file, pick the version to use" while [ "$REPLY" != "L" ] && [ "$REPLY" != "R" ] ; do read -p "Choose L (left/Local) or R (right/Remote): " done; if [ "$REPLY" = "L" ] ; then choice="$local" else choice="$remote" fi; # Returned status is status from cp, which *should* always succeed since they # are all temporary files constructed/consumed by git cp -p "$choice" "$merged"