views:

2434

answers:

7

I'm trying to use Araxis Merge as my diff / merge tool for MSYSGit.

I found a few resources on the net:

  • On the Araxis site, they mention an "easy" way, but it implies a executables (araxisgitdiff.exe and araxisgitmerge.exe) that are not part of my distro.
  • I also found some info in gitguru, but the actual information re: Araxis is sparse at best, and I could not make anything out of that.
  • Finally, there was some info on an older stackoverflow post, but the suggested method doesn't work for me. That particular info was geared towards OS X. I "translated" to Windows as best as I could, but without success:

I created /bin/git-diff-driver.sh

#!/bin/sh

"/c/Program Files/Araxis/Araxis Merge/compare.exe" -title1:"$1 (repo version)" -title2:"$1 " -max "$2" "$5"

and edited gitconfig

[merge]
    tool = araxismerge
[mergetool "araxismerge"]
    cmd = "/c/Program Files/Araxis/Araxis Merge/compare.exe" -3 -merge -wait $LOCAL $BASE $REMOTE $MERGED
[diff]
    external = "/bin/git-diff-driver.sh"

and the only result I get is:

$ git diff HEAD^ HEAD
external diff died, stopping at PowerEditor/src/Notepad_plus.cpp.


Edit:

I've also tried with the exe named as "c:/Program Files/Araxis/Araxis Merge/compare.exe" as suggested by one of the answers, with the same results.


Edit:

I've found that it can easily be set if you use TortoiseGit, but it seems to handle diff by itself and no settings from TortoiseGit give any indication on how to set up Araxis as a merge tool when diff is invoked from the command line.


Edit:

So, the question is: Is there anybody who successfully uses Araxis Merge to diff and merge stuff with MSYSGit, and if so, how do you it?

A: 

You could try to follow the script mentioned in my answer about diffMerge (for Windows) and see if it works.

The executable path could be better expressed with:

#!/bin/sh

"C:/Program Files/Araxis/Araxis Merge/compare.exe" -title1:"$1 (repo version)" -title2:"$1 " -max "$2" "$5"
VonC
Sadly, I get the same result. :-( $ git diff HEAD^ HEADexternal diff died, stopping at PowerEditor/src/Notepad_plus.cpp.
Joce
A: 

I think that you need to be a bit more careful with your escaping in your .gitconfig.

Unfortunately, due to the way the config variable is expanded and evaled, your string needs to be an valid shell command which is then 'git config' escaped.

Try something like this:

[mergetool "araxismerge"]
    cmd = \"/c/Program Files/Araxis/Araxis Merge/compare.exe\" -3 -merge -wait \"$LOCAL\" \"$BASE\" \"$REMOTE\" \"$MERGED\"

Yes, not very pretty, I know. It's one of the cases where using git config directly is actually easier.

git config --global mergetool.araxismerge.cmd '"/c/Program Files/Araxis/Araxis Merge/compare.exe" -3 -merge -wait "$LOCAL" "$BASE" "$REMOTE" "$MERGED"'
Charles Bailey
That's for merge, though. How about diff? Can you set it with `git config -- global` too?
Joce
A: 

One way I found to do it "simply" is to install TortoiseGit and set the diff / merge tools in TortoiseGit options.
However, this does not address the issue if you want to diff from the command line.

Joce
That would mean TortoiseGit has successfully translated that setting into system or global Git properties, no ? What do 'git config --global --list' or 'git config --list' return now ?
VonC
It doesn't look like anything was set by TortoiseGit: http://npp.pastebin.com/f65b60a49 Weird. I wonder how it does it.
Joce
My question exactly. An environment variable perhaps ?
VonC
Hum. There's a tortoisegit.data and a tortoisegit.index in my .git directory. But they are binary and do not appear to contain any reference to Araxis in plain text.
Joce
HA! It's stored in HKEY_USERS\{some-UUID}\Software\TortoiseGit. But I guess that it does not bring me any closer of getting git to use Araxis from the command line.
Joce
A: 

Since I've been bitten to customised git differs/mergers, I thought I would try to fix this one for once and for all. I got to the point where AraxisMerge started, but without the titles of the tabs. So that will be left as an exercise for the reader :)

Observations and comments:

  • I didn't have AraxisMerge, so I downloaded it and got a free 30-days evaluation license to try it out with. This version (7.0 it seems) comes with araxisgitdiff.exe, and the link with instructions you send works. So that would be option #1: upgrade araxis merge.
  • Since I'm working from CMD.EXE, 'git diff HEAD HEAD^' does not work. The '^' needs to be escaped to 'git diff HEAD "HEAD^"'.
  • For my own work I use kdiff3 as a free replacement on Windows which works reasonably well (it helps that it is supported by default by git)

Starting with the git-diff-driver.sh gave the same error to me. After changing the script to only contain 'echo', this did not change. So the error is independent from the contents of the script.

Then I removed the '/bin' part from .gitconfig, so the line becomes

external = "git-diff-driver.sh"

...and this started to work: it started the merger, but it does not escape the '(repo) ' part correctly. As a workaround I got it working without the titles with:

#!/bin/sh
"/c/Program Files/Araxis/Araxis Merge/compare.exe" -max "$2" "$5"

Good luck!

Rutger Nijlunsing
I have some diff and merge scripts working for Araxis, posted in my own answer to this SO question. Could you check them out and tell me if they work for you?
VonC
+1  A: 

Right... I got it working, with msysgit version 1.6.3.2.1299.gee46c, under DOS or Git Bash, with an evaluation license for Araxis Merge 2009, v2009.3713:

The approach is to use the new git difftool and git mergetool, instead of plain diff.

First, let's setup some scripts for those diff and merge tool

C:\>git config --global diff.tool adifftool
C:\>git config --global diff.external git-difftool--helper
C:\>git config --global difftool.adifftool.cmd "difftool.sh \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
C:\>git config --global difftool.prompt false

Notes:

  • by setting diff.external to the Git script git-difftool--helper, I will use difftool even when I will type 'git diff'.
  • do not forget to pass $MERGED to your difftool script: that is the only variable with the real name of the file being diff'ed. $LOCAL and $REMOTE are temporary names.

For the merge tool, you would set the following global values:

C:\>git config --global merge.tool amergetool
C:\>git config --global mergetool.amergetool.cmd "mergetool.sh \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" \"$PWD/$MERGED\""
C:\>git config --global mergetool.prompt false

By setting those tools to some shell scripts, you will be able to switch tools from within those scripts.
Another approach is to name your tools (mergetool.araxis.cmd, mergetool.winmerge.cmd, ...) and to specify the right tool in the diff.tool or merge.tool setting.

Create difftool.sh and mergetool.sh in a directory referenced by your global environment variable PATH. They will work even from DOS (and they are sh -- shell -- scripts)

difftool.sh

#!/bin/sh
echo Launching Araxis Merge.exe: $3
t1="'$3 (from)'"
t2="'(to)'"
"C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -nowait -2 -title1:${t1} -title2:${t2} "$1" "$2"

Notes:

  • Impossible to have -title1:"someTitle With Space"... only title without space does work..., so for now, try it without any 'titleN' option.
    Got it! You cannot pass the title value directly to the -title option, you need to set it to a local variable, with "' '" quotes combinations (the double quotes will disappear during the shell script execution, leaving the simple quotes, allowing spaces within a title!)
  • $3 represent the real name and not some temporary file name for diff purpose. Hence the use of $3 within the title1 option, with space in it.
  • git diff HEAD^ HEAD would not work in DOS session: only git diff "HEAD^" HEAD would.

mergetool.sh

#!/bin/sh

# Passing the following parameters to mergetool:
#  local base remote merge_result

alocal=$1
base=$2
remote=$3
result=$4

t1="'$4 (current branch)'"
t2="'(common ancestor)'"
t3="'(to be merged)'"

if [ -f $base ]
then
    "C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -wait -merge -3 -a2 -title1:${t1} -title2:${t2} -title3:${t3} "$alocal" "$base" "$remote" "$result" 
else
    "C:/Program Files/Araxis/Araxis Merge/Compare.exe" -max -wait -merge -3 -a2 -title1:${t1} -title2:${t2} -title3:${t3} "$alocal" "$result" "$remote" "$result" 
fi

I am not sure I those scripts do work properly when multiple files are involved (multiple diffs, multiple files to be merged).
Just tested it: it works, and Araxis compare.exe does open one tab per file to diff or merge.
Give it a try and let us know ;)

VonC
I had to prefix the $ in $LOCAL, etc with a backslash ('\'). Then it worked.
Mike Caron
@Mike: Thank you for this feedback. Were you within a DOS session or a bash shell session when you has to escape those `$` for the `git config` parameters?
VonC
Thell did just drop a much more compact answer.
Joce
A: 

If you want to have 'git diff' always use araxis you can use the instructions in the help file, but if you want to have control to use 'git diff' as you normally would from the command line and 'git difftool' to engage the Araxis GUI.

Try adding the following to your git config::

[difftool "araxis"]
    path = "/c/Program Files/Araxis/Araxis Merge/compare.exe"
    renames = true
    trustExitCode = true
[diff]
    tool = araxis
    stat = true
[mergetool "araxismergetool"]
    cmd = 'C:\\Program Files\\Araxis\\Araxis Merge\\araxisgitmerge.exe' "$REMOTE" "$BASE" "$PWD/$LOCAL" "$PWD/$MERGED"
    trustExitCode = false
[mergetool]
    keepBackup = false
[merge]
    tool = araxismergetool
    stat = true
Thell
A: 

I struggled with this problem for quite a while, and now I finally can say, that all suggested dirty hacks (like intermediate shell scripts) are rather unnecessary =D. Thing is, all of the latest versions of MSYSGit (I have 1.6.4) support Araxis Merge (I have 2008) out of the box. It comes at no surprise, that internally it's called "araxis". So, all that you need is to set

[merge]
    tool = araxis

in your .gitconfig. Also you have to include Araxis folder into your PATH environment variable (MSYSGit looks for Compare.exe).

For a good measure, other Git settings related to "araxis" mergetool, that you could have configured (especially, if you happen to choose exactly that name, as did some people on this page), should all be removed. That includes everything under [mergetool "araxis"] section. Be sure to remove them from all configs (system, global, and repository), otherwise, they might interfere with normal "internal tool" behavior.

In any case, if you're interested in how MSYSGit will start your Araxis Merge, or wondering what other mergetools it supports out of the box, the place to look is \share\git-gui\lib\mergetool.tcl script in your MSYSGit installation folder.

PS. You might be able to avoid setting PATH environment variable, by configuring mergetool.araxis.path in .gitconfig. Personally, I never bothered to do so, since

  1. I use Araxis Merge from command line anyway.
  2. Specifying directory path in .gitconfig (especially the one like "C:\Program Files\Araxis\Araxis Merge\", which contains spaces) can prove hard to be done correctly, since it is prone to backslash/forwardslash issues, that plague MSYSGit.

PPS. All of the above applies to making Araxis your difftool, too. I.e, you need to add

[diff]
    tool = araxis

and remove anything else in [difftool "araxis"] section, if you have it in your config (don't forget to set up PATH, though).

nightingale
Thanks! I'll give it a try as soon as I update to the latest git.
Joce
Hope it will help, then. But I'm not sure that you have to wait at all - at least you can check, whether the word "araxis" (without quotes) is present in your \share\git-gui\lib\mergetool.tcl. It's just a matter of opening .tcl with notepad and using text search. Presence of the word is a clear indication that your current MSYSGit already supports Araxis. Provided 1) the above, 2) that you didn't have configured a custom mergetool that you called "araxis" 3) Araxis folder is mentioned in PATH, you can try it out without any additional configuration by invoking "git mergetool --tool=araxis".
nightingale
As a matter of fact, you can just try invoking "git mergetool --tool=araxis" right away. MSYSGit should tell you, whether it knows a tool with such name, and if it does, whether it can find required executable. If you're lucky, it would just magically work without any effort on your part whatsoever. =)
nightingale
(forgot to mention) You should have an unresolved merge conflict in your tree for "git mergetool" to say something sensible about the tool. Otherwise Git won't feel a need to check for tool's presence, etc.
nightingale
I just tried `git difftool --tool=araxis` but got the error message: _The diff tool araxis is not available as 'compare'_. Any ideas?
Drew Noakes
Sorry, I was too late to respond to you, Drew, but I hope it'll help to the next person out there. =/ Well, the basic idea in that case is that Git is aware of the "araxis" mergetool, i.e. it has some configuration regarding it, e.g. that the executable that needs to be called is named "compare". But it was unable to locate the executable itself. The simplest way to amend that, is to add the path to Araxis (e.g. "C:\Program Files\Araxis\Araxis Merge\") into PATH environment variable. Of course, explicitly specifying path to the mergetool in .gitconfig, as explained above, should help too.
nightingale
If, for some reason, all of the above doesn't help, i.e you're absolutely sure, that you've set up your PATH properly and removed all remnants of mergetool sections from your .gitconfigs, that you could've possibly put there, then I'm out of ideas, too. You may try renaming Araxis's Compare.exe (which is its usual name) to all-lowercase ("compare.exe"), in case that (originally made for linux, and therefore - a case-sensitive util) git is being picky. But frankly, I highly doubt it.
nightingale