RSS

Using Araxis Merge with Git

11 Feb

I wanted to use the great Araxis Merge tool as a helper to solve merge conflicts with Git but currently it is not supported out-of-the-box. Luckily new commands can be configured by hand but a quick Google search didn’t turn up anything I could have simply copy-pasted to get it working. So here goes..

I assume that you’ve got Araxis Merge installed including the binaries that are located in the “Utilities” directory in the distribution. It doesn’t matter where you place the binaries as long as they are available. I put them under /usr/local/bin on my Mac.

In case of a merge conflict there are two possible scenarios: one, in which a common base version exists and second, where it does not exist. These scenarios require the use of a three-way-diff or a two-way-diff operation, respectively. The command line options for Araxis Merge require that we know in advance which scenario we are facing so I had to resolve to using a simple shell script wrapper that would make the appropriate call to the compare binary. The shell script I used is below.

#!/usr/bin/env bash

LOCAL=$1
REMOTE=$2
MERGED=$3
BASE=$4

MERGE=/usr/local/bin/compare

if [ -e "$BASE"  ]; then
    $MERGE -wait -merge -3 -a1 \
    -title1:"$MERGED (Base)" \
    -title2:"$MERGED (Local)" \
    -title3:"$MERGED (Remote)" \
    "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
else
    $MERGE -wait -2 \
    -title1:"$MERGED (Local)" \
    -title2:"$MERGED (Remote)" \
    "$LOCAL" "$REMOTE" "$MERGED"
fi

To get it working I saved the shell script in /usr/local/bin/araxis-mergetool, made it executable and configured Git as follows

git config --global mergetool.araxis.cmd \
  'araxis-mergetool "$LOCAL" "$REMOTE" "$MERGED" "$BASE"'
git config --global merge.tool araxis

Now, when I get merge conflicts I can run git mergetool and Araxis Merge will be opened up in the proper mode with the conflicting files.

Unfortunately Araxis Merge and the compare binary do not appear to set the exit code of the process in a manner that Git would understand so after fixing up the conflict I may still need to tell Git whether the merge was successful or not.

Advertisements
 
2 Comments

Posted by on February 11, 2009 in git

 

2 responses to “Using Araxis Merge with Git

  1. Ben

    June 2, 2009 at 20:47

    Araxis now bundles two git diff/merge utilities araxisgitdiff and araxisgitmerge. See http://www.araxis.com/merge_mac/scm_integration.html#Git

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: