2

I'm having trouble trying to use git difftool (in this case, opendiff for mac) to visualise the differences made in the latest git commit. I don't want to launch opendiff for each pair of files that has changed, I just want to launch one instance of opendiff which compares the entire directory, so I've followed the advice from this answer which is to use --dir-diff. I ended up using this command:

git difftool HEAD^ HEAD --dir-diff

The problem is that when I launch this command, the opendiff says that there are 0 differences (even though using normal diff will show differences in multiple files). What's going on? How do I use difftool correctly?

Community
  • 1
  • 1
Eddy
  • 6,211
  • 20
  • 56
  • 70
  • That answer specifies that the diff tool must be able to "compare two directory hierarchies at a time after populating two temporary directories". Can `opendiff` do that? – Chris Jun 29 '14 at 14:37
  • The command you provided works well for me with `meld` on Linux. Maybe `opendiff` issue? – buff Jun 29 '14 at 15:00
  • Perhaps `git log -p -1` would be useful? – twalberg Aug 27 '14 at 14:22

1 Answers1

1

The files get deleted immediately because opendiff (the command line tool) exits straight after launching FileMerge (the GUI tool). You need to write a short wrapper script that will copy the left and right folders to (another) temp location and start opendiff with those locations.

Edit: you can configure a custom difftool that will start FileMerge directly and wait for it to exit. Add this to your ~/.gitconfig

[difftool "fm"]
cmd = /Applications/Xcode.app/Contents/Applications/FileMerge.app/Contents/MacOS/FileMerge -left \"$LOCAL\" -right \"$REMOTE\"
path =
Steven Kramer
  • 8,433
  • 2
  • 35
  • 43