I can't make git diff use opendiff
Asked Answered
C

3

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!

Cleanse answered 15/6, 2011 at 5:50 Comment(3)
Is it reporting an error? Or just giving a regular built-in diff?Secund
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.Cleanse
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?Rael
T
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!

Tracytrade answered 28/3, 2012 at 9:14 Comment(1)
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.shHilariohilarious
Z
2

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

chmod +x ~/opendiff-git.sh
Zo answered 15/6, 2011 at 6:41 Comment(0)
T
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!

Tracytrade answered 28/3, 2012 at 9:14 Comment(1)
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.shHilariohilarious
B
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.

Bouillon answered 24/10, 2013 at 1:19 Comment(1)
does not work on macOS Sierra and git version 2.10.1 (Apple Git-78)Gpo

© 2022 - 2024 — McMap. All rights reserved.