Git difftool not launching external DiffMerge program

EmmyS picture EmmyS · Jun 12, 2014 · Viewed 16.1k times · Source

I've been following the directions in the "blog entry by Dave" link in this answer as I'm on Windows 7 and do use SourceGear's DiffMerge tool. I've added the git\cmd directory to my PATH system variable and put my git-diff-diffmerge-wrapper.sh file in there:

#!/bin/sh
"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$1" "$2" | cat

(Yes, it's the correct path for DiffMerge.)

I've edited my .gitconfig file to include the diff and difftool chunks (I copied the lines directly from the post, and he does leave in the commented-out #external line. I added this to the end of my file; is that OK? )

[diff]
    # external = git-diff-wrapper.sh
    tool = diffmerge
[difftool "diffmerge"]
    cmd = git-diff-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"

So I go to git bash and do git difftool HEAD~ 67b8679 -- js/site/pizzabuilder.js and hit enter. Nothing happens. If I do git difftool HEAD~ 67b8679, leaving off the file I want, I get this:

Viewing: 'js/angular/hutlovers/hutlovers.js'
Launch 'diffmerge' [Y/n]: Y
C:\Program Files (x86)\Git/libexec/git-core/mergetools/defaults: line 17: git-diff-diffmerge-wrapper.sh: command not found

Viewing: 'js/angular/localization/StoreListCtrl.js'
Launch 'diffmerge' [Y/n]: n

Viewing: 'js/pizzahut/site/browser_version.js'
Launch 'diffmerge' [Y/n]: n

Viewing: 'js/pizzahut/site/dashboard.js'
Launch 'diffmerge' [Y/n]: n

It continues for all of the files that are different between the commits, but it never launches DiffMerge. I don't know how to interpret the error; what command is not found? difftool? I'm running 1.7.11 in git, and difftool is supposedly included with git starting with version 1.6.3.

When I look at line 17 of the file referenced in the error, this is what's there:

( eval $merge_tool_cmd )

as part of this block:

diff_cmd () {
    merge_tool_cmd="$(get_merge_tool_cmd "$1")"
    if test -z "$merge_tool_cmd"
    then
        status=1
        break
    fi
    ( eval $merge_tool_cmd )
    status=$?
    return $status
}

Can anyone help me out? I'm a daily user of git, but hardly a power user, and I know nothing about Windows shell scripts, so following the directions in that post is pretty much the limits of my knowledge at this point.

Answer

TyCobb picture TyCobb · May 29, 2018

I know this is an old question and I recognize that my situation may just be me being dumb, but I did spin my wheels trying to figure this out. Hopefully though, someone who made the same mistake as me won't be completely lost in future.


Make sure items show with git diff!

I had a very simple one line change. Did a git add . and then got interrupted. Came back to finish up and decided to double check the diffs. I did not realize that doing a git add would stop me from being able to use git difftool.

Doing a git reset allowed git difftool to work.