7

I want to use opendiff as default diff-tool for git diff. This used to work but for some reason stopped working. I'm using a script:

echo opendiff $2 $5 > opendiff-git.sh

which is set in .gitconfig:

[diff]
external = ~/opendiff-git.sh

This stopped working for me lately. What is wrong?

Update: When I cloned a new repository everything worked fine! Strange!

Ida
  • 173
  • 9
  • Is it reporting an error? Or just giving a regular built-in diff? – cxreg Jun 15 '11 at 05:59
  • No it's not reporting an error when using git diff it just print the diff in the terminal. I can also use opendiff by itself. – Ida Jun 15 '11 at 06:57
  • I have the exact same problem in Mac OS X. Before, opendiff worked great even without setting this shell script. After it stopped working, I added the script and the diff.tool and diff.external options but it still doesn't work. And it does not give an error, just makes a terminal diff. What can be happening? – Petruza Jan 21 '13 at 12:26

3 Answers3

2

make sure your opendiff-git.sh file has its executable bits set:

chmod +x ~/opendiff-git.sh
knittl
  • 246,190
  • 53
  • 318
  • 364
2

I found this question while I was trying to set opendiff as my git diff & merge tool. Weird thing is that when I used the echo opendiff $2 $5 > opendiff-git.sh to create a script the script did not contain the argument place holders $2 $5 I added them in manually and it started working!

This command

echo opendiff $2 $5 > opendiff-git.sh

Resulted in opendiff-git.sh file containing

opendiff

I added the two argument placeholders $2 $5 manually

opendiff $2 $5

Made the shell script executable as suggested by knittl

chmod +x ~/opendiff-git.sh

And it works!

John
  • 68
  • 9
  • 2
    You have to escape the '$' on the command line or the shell triest to find variables with the names '$2' and '$5', which didn't exist so they were substituted with empty string. Try to run this instead: echo opendiff \$2 \$5 > ~/opendiff-git.sh – petrsnd Sep 14 '12 at 21:44
1

You can now specify a default tool using git config. To use FileMerge, i.e. opendiff, run:

git config --global diff.tool opendiff

If you view your ~/.gitconfig file, you should now see:

[diff]
    tool = opendiff

It should now work.

shadowmatter
  • 1,352
  • 2
  • 18
  • 30