gvimdiff mergetool for msysgit
Asked Answered
T

2

10

I'm trying to use gvimdiff as a mergetool for git on Windows. Previously I've used vimdiff in console mode, but know feel like I'm not happy with limiting view Windows console size, so I'm trying to switch to gvimdiff which have more flexible approach to setting window size.

But trying to call git mergetool now I'm receiving error which is not clear for me:

The merge tool gvimdiff is not available as 'gvim'

How this could be resolved?

gvim for Windows is install and accessible via command line. The same is true for gvimdiff command.

I'm trying to find the place where this error is raised in git scripts, but currently with no luck.

Threw answered 14/6, 2012 at 7:52 Comment(4)
A side note: you can change cmd's default size by right clicking on the top-bar -> properties and something there. While you are there, you can also tell it to initialize every window at the same starting position. Then once you click ok, it asks if you want to set it as default or only for this window.Countermine
It does not help for me in this particular case... the code I'm trying to merge have huge indentations and length of the lines, so I plan gain some more pixels (g) by setting small but readable font in gvimdiff...Threw
The error is raised in the get_merge_tool_path function inside $(git --exec-path)\git-mergetool--lib. When you configure gvimdiff as your merge tool, git internally translates that to a gvim command (see $(git --exec-path)\mergetools\vim. From the shell that you launch git mergetool, you must be able to run gvim. If that works, then git mergetool should as well.Sectorial
@TimHenigan I'm afraid your comment is necessarily wrong because I can run gvim and vim from the Cmder console but I get the same error when I run git mergetool. Regretfully, I still don't know why.Reconcile
B
9

If you start a Git console, are you sure the commands are accessible? I'm suspecting that it is not on the PATH of your Git console, only the Windows PATH (which is not entirely included).

Bracken answered 14/6, 2012 at 9:9 Comment(5)
He is opening a GVim window, not a console. Although git console not grabbing PATH is annoying as hellCountermine
@Shahbaz: Actually git is attempting to open the gvim, not the user. To test that PATH is set up properly, the user must check if he can execute gvim from the same shell that he is running git mergetool.Sectorial
You're right the Windows PATH variable was omitted. I didn't know how to add it to the msysgit environment, so I've just created file c:\Program Files (x86)\Git\bin\gvim with following contents: #!/bin/sh exec "/c/Program Files (x86)/Vim/vim73/gvim.exe" "$@" And it worked!Threw
Yeah, glad to hear it helped.Bracken
I combined this answer and one below to create /usr/local/bin/gvimdiff #!/bin/bash /c/PROGRA~2/Vim/vim74/gvim -d "${LOCAL}" "${REMOTE}"Lemma
J
3

Combining your answers, these are my settings

.gitconfig

[alias]
    d = difftool
[diff]
    renames = copy
    tool = gvimdiff
[difftool "gvimdiff"]
    cmd = "gvim -d" "$LOCAL" "$REMOTE"
[difftool]
    prompt = false

And added file gvim accessible in %PATH% with content:

"C:\Program Files (x86)\Vim\vim73\gvim.exe" "$@"

Git difftool in Windows to see list of all changed files in addition to file diffs (a la Kaleidoscope)?

Jadajadd answered 3/3, 2014 at 18:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.