Meaningful names using git difftool?

Viewed 41

I'm not entirely sure if this is an issue with git difftool, but when I use it with a custom difftool it shows random prefixes to the filename I'm diffing on both sides. uZl7iq_README.txt vs hO7k5f3_README.txt, for example. I'm pretty confident that left and right correspond to the first and second commit hashes that I provide to difftool, and of course a little investigation proves/disproves that, but it would be really nice if the prefix could reflect the either the branch name I provided or the commit it resolves to. Anyone know of a workaround?

1 Answers

Maybe, depends on the details of the diff tool.

git diff is aware of Git and can look up the contents of particular revisions in Git on its own and display the filename from Git.

git difftool uses an external diff program of your choice. These programs know nothing about Git. git difftool writes the contents to be diffed to temp files. Then it runs a script to execute the diff program. $LOCAL and $REMOTE are the temp files to be diffed. $MERGED and $BASE are name of the file in Git. You can see these by using the echo difftool.

If there is a way to tell the diff program "diff $LOCAL and $REMOTE, but pretend they are actually called $MERGED", then yes, you can write a wrapper script which will display the Git filename.

Related