-->

git for Windows: tortoisegitmerge can only be laun

2019-06-14 11:08发布

问题:

I'm using 64 bit git-for-windows 2.12.2 under Windows7 64 bit system. Also, I have 64 bit TortoiseGit 2.4.0 installed under E:\Program Files\TortoiseGit. Now, I have try to set the tortoisegitmerge.exe as a merge tool, then use it under either bash and git gui.

Here is my setting of global .gitconfig file:

[merge]
    tool = tortoisemerge    
[mergetool "tortoisemerge"]
    path = E:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe

This setting is from the one answer here: git - Why doesn't tortoisemerge work as my mergetool? - Stack Overflow

This works fine if I try to launch the merge tool from the command line, see the log below:

123@123-PC MINGW64 /d/code/cb/cb_sf_git/trunk (test_merge_gui|AM 3/19)
$ git mergetool
Merging:
src/CodeBlocks_wx31.cbp

Normal merge conflict for 'src/CodeBlocks_wx31.cbp':
  {local}: modified file
  {remote}: modified file

123@123-PC MINGW64 /d/code/cb/cb_sf_git/trunk (test_merge_gui|AM 3/19)
$ git am --continue

You can see the image shot of the opened window after I run git mergetool, it looks like tortoisegitmerge already fix the conflict, so I just click Save button, and close the tortoisegitmerge, and run git am --continue.

But when conflict happens, I can open the git gui gui tool, and see the image shot here, look, it shows one conflict here.

When I right click and click the "merge tool" context menu, I get such error message box, it said: "Unsupported merge tool 'tortoisemerge'", see image shot below:

While, I have tried other settings in .gitconfig, such as this one:

[merge]
        tool = tortoisemerge
[mergetool "tortoisemerge"]
        cmd = '"E:/Program Files/TortoiseGit/bin/TortoiseGitMerge.exe" -base:"$BASE" -theirs:"$REMOTE" -mine:"$LOCAL" -merged:"$MERGED"'

But there are still other errors when launched either from bash, see below:

123@123-PC MINGW64 /d/code/cb/cb_sf_git/trunk (test_merge_gui|AM 3/19)
$ git mergetool
Merging:
src/CodeBlocks_wx31.cbp

Normal merge conflict for 'src/CodeBlocks_wx31.cbp':
  {local}: modified file
  {remote}: modified file
/mingw64/libexec/git-core/git-mergetool--lib: line 128: E:/Program Files/TortoiseGit/bin/TortoiseGitMerge.exe -base:$BASE -theirs:$REMOTE -mine:$LOCAL -merged:$MERGED: No such file or directory
src/CodeBlocks_wx31.cbp seems unchanged.
Was the merge successful [y/n]?

While try to launch the merge tool from context menu of git gui, I get the same message box saying "Unsupported merge tool 'tortoisemerge'".

I have tried other settings of the cmd or path field, but without any luck, all get failed.

Any one can help? Thanks.

EDIT: I have tried all the settings in this stackoverflow questions: Why can't I use TortoiseMerge as my git merge tool on Windows? - Stack Overflow, but no luck, all are failed with the same error.

回答1:

After debugging for a while, I think I have totally fix this issue, just add a code snippet in the file mergetool.tcl.

tortoisemerge {
    #set cmdline [list "$merge_tool_path" -base:"$BASE" -mine:"$LOCAL" -theirs:"$REMOTE" -merged:"$MERGED"]
    #Note: no quote around the $BASE like variables, because those cause escaped quote
    #and it looks like TortoiseGitMerge does not support such formats.
    set cmdline [list "$merge_tool_path" -base:$BASE -mine:$LOCAL -theirs:$REMOTE -merged:$MERGED]
}

Then the problem could be solved. See some discussion here: google group discussion.