git difftool will tell you what it's going to try.
$ git difftool
This message is displayed because 'diff.tool' is not configured.
See 'git difftool --tool-help' or 'git help config' for more details.
'git difftool' will now attempt to use one of the following tools:
kompare emerge vimdiff
Viewing (1/1): 'this'
Launch 'emerge' [Y/n]?
We can find the process in the guess_merge_tool function.
guess_merge_tool () {
list_merge_tool_candidates
cat >&2 <<-EOF
This message is displayed because '$TOOL_MODE.tool' is not configured.
See 'git ${TOOL_MODE}tool --tool-help' or 'git help config' for more details.
'git ${TOOL_MODE}tool' will now attempt to use one of the following tools:
$tools
EOF
# Loop over each candidate and stop when a valid merge tool is found.
IFS=' '
for tool in $tools
do
is_available "$tool" && echo "$tool" && return 0
done
list_merge_tool_candidates sets up the list of $tools. It assumes that if DISPLAY is not set you do not have a GUI which is incorrect on MacOS.
Then it simply loops through them and picks the first one it finds an executable for using type.
UPDATE
I've met some weird diff result when I execute git diff(I suspect BOM handling issue). I'd like to question the vendor(e.g., p4merge) about it,
but not sure if it is p4merge, vimdiff or anything else.
If you're having an issue with git diff that is with git diff not git difftool. I think there's some confusion about what git difftool does, so here's a quick overview.
git diff does not use git-difftool. git difftool does not pick the diff tool for git diff. git diff has its own internal diff implementation. It can also use an external diff program, like GNU diff, by supplying --ext-diff.
When you run git difftool it picks an external diff program and runs it with three environment variables: $LOCAL, $REMOTE, and $MERGED. $LOCAL is a path to the old version of the file, $REMOTE to the new, and $MERGED to the name of the file so it can be displayed. That's about it. It has no relation to git diff.
We can see what git difftool does by adding to custom difftools to .gitconfig:
[difftool "echo"]
cmd = echo "LOCAL: $LOCAL, REMOTE: $REMOTE, MERGED: $MERGED"
[difftool "less"]
cmd = less "$LOCAL" "$REMOTE"
git difftool -t echo will show the environment variables. git difftool -t less will look at the contents of the old and new versions of the files in the less pager.
If you're having a problem with git diff, git difftool has nothing to do with it. Nor should p4merge nor vimdiff.