Automatically let git open custom merge tool for certain extensions

293 Views Asked by At

I've written a small custom diff/merge tool to visually merge PowerPoint files. It launches PowerPoint in Compare/Merge mode.

I'm trying to register it as the default tool git should use when diffing and merging any powerpoint files.

I added the following to the .gitconfig:

[difftool "pptdiffmerge"]
    name = PowerPoint Diff tool
    cmd = C:/ppt-diffmerge-tool/bin/Debug/ppt-diffmerge-tool.exe "$LOCAL" "$REMOTE"
    binary = true
[mergetool "pptdiffmerge"]
    name = PowerPoint Merge tool
    trustExitCode = false
    keepBackup = false
    cmd = C:/ppt-diffmerge-tool/bin/Debug/ppt-diffmerge-tool.exe "$LOCAL" "$REMOTE" "$BASE" "$RESULT"

And this to the .gitattributes:

*.ppt   binary diff=pptdiffmerge merge=pptdiffmerge
*.pptm  binary diff=pptdiffmerge merge=pptdiffmerge
*.pptx  binary diff=pptdiffmerge merge=pptdiffmerge

And when I run git difftool --tool-help my custom tool is listed:

C:\Users\jesse\source\repos\ppt-diffmerge> git difftool --tool-help
'git difftool --tool=<tool>' may be set to one of the following:
                vimdiff
                vimdiff1
                vimdiff2
                vimdiff3

        user-defined:
                pptdiffmerge.cmd C:/ppt-diffmerge-tool/bin/Debug/ppt-diffmerge-tool.exe $LOCAL $REMOTE
                pptdiffmerge.cmd C:/ppt-diffmerge-tool/bin/Debug/ppt-diffmerge-tool.exe $LOCAL $REMOTE $BASE $RESULT

So far so good...

But when I run git difftool sample.pptx, it doesn't suggest to use mine. When I call git difftool sample.pptx -tpptdiffmerge, then it does work.

What am I missing here...

0

There are 0 best solutions below