tags:

views:

2883

answers:

5

Gitx has a great diff viewer, how do I make git automatically pipe git diff whatever into gitx?

I've tried to set git config diff.external to a shell script that looks like this:

git diff "$2" "$5" | gitx

However, that only opens all the individual files up into multiple gitx windows, and it really messes up the files names (changes them all to tmp files with crazy names).

Does anyone have a better solution?

+2  A: 

I'm sorry this doesn't really answer your question about gitx. I'm not even sure if gitx can function as a generic diff tool. You might like FileMerge, a merge/diff tool included in the Xcode install. There is a script called opendiff that can launch it for you. Simply make a script with the following line in it and point diff.external at it.

opendiff $2 $5
sigjuice
+1 for opendiff, but I just use it to view diff, not edit.
claferri
+1  A: 

I asked a similar question a while back. That answer may help you. There are a couple of questions in there, but one has to do with opening a diff view in something other than FileMerge.

Rob Wilkerson
+2  A: 

I did this for Araxis merge, but modifying these basic instructions should not be hard for whatever you perferred tool is.

First I created ~/bin/git-diff-driver.sh and added execute permission to the file.


#!/bin/sh

/usr/local/bin/compare -title1:"$1 (repo version)" -title2:"$1 " -max "$2" "$5"

Araxis installs it's command line interface tools in /usr/local/bin The compare tool is their generic tool and the araxis* tools feed through compare.

Once this is set up the following lines need to be added to ~/.gitconfig


[merge]
    tool = araxismerge
[mergetool "araxismerge"]
    cmd = "/usr/local/bin/compare -3 -merge -wait $LOCAL $BASE $REMOTE $MERGED"
    path = /usr/local/bin/
[diff]
    external = "/Users/mark/bin/git-diff-driver.sh"

This redirects all 2-way and 3-way diffs through Araxis Merge. It seems like the "path =" shouldn't be necessary, but it works.

Good Luck.

Mark Thalman
+4  A: 

like sigjuice is saying up there. Only that noobs (like i am now) need to know how to "connect" git to use it. Here is what I did

echo 'opendiff $2 $5' > ~/opendiff-git.sh
chmod a+x ~/opendiff-git.sh
git config --global diff.external ~/opendiff-git.sh

and now all "git diff whatever" should open FileMerge.app ...

Wolfram Kriesing
+1  A: 

I am not quite sure this is what you want but for us on Macs it sure is handy anyway and somewhat related, you might want to try:

git diff-tool -t opendiff #hash

That opens the diff in the open diff program which I find very useful. If you are not on a Mac you can probably change the opendiff into your favorite available diff tool...

jonalv
make that “git difftool…” (w/o dash)
plindberg