How to launch tortoisegitmerge from git gui context menu?

440 views
Skip to first unread message

asmwarrior

unread,
Apr 23, 2017, 2:44:52 PM4/23/17
to git-for-windows
When I use the "git am" command to apply a serial of patches, I see conflicts, so I opened the "git gui", and try to launch the tortoisegitmerge.exe from the context menu "Run Merge Tool", but it just failed saying "Unsupported merge tool 'tortoisemerge".

But the strange thing is I can launch the tortoisegitmerge from the bash command line "git mergetool".
So, are there two settings for the same merge tool? I think if I can run the "git mergetool", than my setting of the mergetool is correct, but why I can't launch it from git tui?

The more detailed steps are posted in my Stackoverflow post here two weeks ago: http://stackoverflow.com/questions/43317998/git-for-windows-tortoisegitmerge-can-only-be-launched-from-bash-command-line-b
But unluckily, there are no answers yet. So, I'm asking this question here, thanks.

Asmwarrior

Philip Oakley

unread,
Apr 23, 2017, 10:35:11 PM4/23/17
to asmwarrior, git-for-windows
Hi,
 
I've commented on the SO question:
 
The message appears to be from L275 of C:\git-sdk-32\usr\src\git-gui\lib\mergetool.tcl (on my local mc).
 
 
It looks like the git-gui hand codes each of the different command lines, and that doesn't include TortoiseGit.
 
Maybe the next challenge is a neat little patch to pick up the cmd line from the config.
 
--

Philip Oakley

unread,
Apr 24, 2017, 10:37:06 PM4/24/17
to Philip Oakley, asmwarrior, git-for-windows
This onwardly linked So answer essentially spells out a patch...
 
Philip
--
You received this message because you are subscribed to the Google Groups "git-for-windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to git-for-windo...@googlegroups.com.
To post to this group, send email to git-for...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/git-for-windows/4EBBE9D227C84FF88850B27B04192910%40PhilipOakley.
For more options, visit https://groups.google.com/d/optout.

Philip Oakley

unread,
Apr 24, 2017, 10:58:15 PM4/24/17
to asmwarrior, git-for-windows

asmwarrior

unread,
Apr 27, 2017, 2:48:08 PM4/27/17
to git-for-windows, asmwa...@gmail.com, philip...@iee.org
On Tuesday, April 25, 2017 at 6:58:15 AM UTC+8, Philip Oakley wrote:

Hi, Philip, thanks for the help. Sorry for the late reply.

I have just tried the method you mentioned in http://stackoverflow.com/a/15984079/154911
And It looks like the TortoiseGitMerge executable is launched from the GitGui, but TortoiseGitMerge just report some error message.
This is exact same error in this post here:
msysgit - Git gui mergetool TortoiseMerge wrong file path - Stack Overflow - http://stackoverflow.com/questions/19819263/git-gui-mergetool-tortoisemerge-wrong-file-path
Though the above question is asked in 2013 which is msys, but it has the same error message here for the latest git-for-windows and latest TortoiseGitMerge.

Any ideas?

Asmwarrior


 

Philip Oakley

unread,
Apr 27, 2017, 8:23:18 PM4/27/17
to asmwarrior, git-for-windows, asmwa...@gmail.com
Try a message box showing the command line just before the command invocation.
 
You may find that some of the paths are in POSIX format,or have wrong way dir separators, or the colon (drive) isn't liked, or the drive letter needs capitalised, etc etc. (or even that it can't handle blank or empty paths "")
 
The old ways are still effective ;-)
 
Philip
----- Original Message -----
From: asmwarrior
Sent: Thursday, April 27, 2017 3:48 PM
Subject: Re: [git-for-windows] How to launch tortoisegitmerge from git gui context menu?

asmwarrior

unread,
Apr 28, 2017, 3:16:22 PM4/28/17
to git-for-windows
On 4/28/17 4:23 AM, Philip Oakley wrote:
Try a message box showing the command line just before the command invocation.
 
You may find that some of the paths are in POSIX format,or have wrong way dir separators, or the colon (drive) isn't liked, or the drive letter needs capitalised, etc etc. (or even that it can't handle blank or empty paths "")
 
The old ways are still effective ;-)
 
Philip
Thanks for the hint, I just did some test, but all got failed.
First, I try to use such code to show file paths:

    tortoisemerge {
         set cmdline [list "$merge_tool_path" -base:"$BASE" -mine:"$LOCAL" -theirs:"$REMOTE" -merged:"$MERGED"]
        error_popup [mc "command line: '%s'" $cmdline]
    }

Then I try to change the code
snippet(in the file mergetool.tcl)

From
    set MERGED   $current_diff_path
    set BASE     "./$MERGED.BASE$fileext"
    set LOCAL    "./$MERGED.LOCAL$fileext"
    set REMOTE   "./$MERGED.REMOTE$fileext"
    set BACKUP   "./$MERGED.BACKUP$fileext"

To


    set MERGED   $current_diff_path
    set BASE     "$MERGED.BASE$fileext"
    set LOCAL    "$MERGED.LOCAL$fileext"
    set REMOTE   "$MERGED.REMOTE$fileext"
    set BACKUP   "$MERGED.BACKUP$fileext"

It did show a dialog box, and it looks like there are no errors here, see the dialog below:



This look OK from my point, but continue running, I get such error message(It is the same message
as seen from the stackoverflow site: msysgit - Git gui mergetool TortoiseMerge wrong file path - Stack Overflow -
http://stackoverflow.com/questions/19819263/git-gui-mergetool-tortoisemerge-wrong-file-path



So, I have no idea how to tweak the paths. :-(

Thanks.

Asmwarrior


Philip Oakley

unread,
Apr 28, 2017, 5:05:45 PM4/28/17
to git-for-windows, asmwarrior
Ah, I think I may see it.
 
Well done for the debugging and careful documenting of the response.
 
What I see is in the TortoiseGit merge dialog window
 
 
Where it shows the file it can't open as:
'\"src\CodeBlocks_wx31.cbp.BASE.cbp\"' (then the colon and the other language encoded string)
 
In particular there is the very front part that prefixes the double quoted path string with the backslash dir separator.
 
I am guessing that that prefix formation is very wrong and the dq should be the other side of the dir_sep char.
 
Check whether the prefix is added by Git, or by TortoiseGit. I
 
t may even be an attempt at backslash quoting in the tcl (different systems fighting over who gets to 'do the right thing'!).
 
I had a similar issue with a recent small patch to the gui for duplicate file entries in the resently used config variable. (it's one of the issues.. (https://public-inbox.org/git/20170122195301.17...@iee.org/ 
 
https://github.com/git-for-windows/git/issues/1014
 
Hope that helps
 
----- Original Message -----
From: asmwarrior
Sent: Friday, April 28, 2017 4:16 PM
Subject: Re: [git-for-windows] How to launch tortoisegitmerge from git gui context menu?

--
You received this message because you are subscribed to the Google Groups "git-for-windows" group.
To unsubscribe from this group and stop receiving emails from it, send an email to git-for-windo...@googlegroups.com.
To post to this group, send email to git-for...@googlegroups.com.
bchgpaaamghgheeh.png
hebjecgajgblikgk.png

asmwarrior

unread,
Apr 29, 2017, 12:18:25 PM4/29/17
to git-for-windows
On 4/29/17 1:05 AM, Philip Oakley wrote:
Ah, I think I may see it.
 
Well done for the debugging and careful documenting of the response.
 
What I see is in the TortoiseGit merge dialog window
 
 
Where it shows the file it can't open as:
'\"src\CodeBlocks_wx31.cbp.BASE.cbp\"' (then the colon and the other language encoded string)
Hi, Philip Oakley, thanks for the reply.

The other language encoded string is in Chinese language, it said: filename or directory is not correct.
It looks like tortoisegitmerge.exe can't not accept the \"filepath\" as a filename parameter.
What's the interesting thing is, in my .gitconfig file, I have such settings:
[mergetool "tortoisemerge"]
  cmd = "\"E:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe\" -base:\"$BASE\" -mine:\"$LOCAL\" -theirs:\"$REMOTE\" -merged:\"$MERGED\""
  path = E:\\Program Files\\TortoiseGit\\bin\\TortoiseGitMerge.exe

The cmd field is used by the bash command "git mergetool", it did use the escape chars.
The path field is used by the gitgui (in mergetool.tcl as the variable "$merge_tool_path")

I tried to change the code in mergetool.tcl to this:

    set MERGED   $current_diff_path
    set BASE     $MERGED.BASE$fileext
    set LOCAL    $MERGED.LOCAL$fileext
    set REMOTE   $MERGED.REMOTE$fileext
    set BACKUP   $MERGED.BACKUP$fileext
Note I have remove those double quote, but still no success.


 
In particular there is the very front part that prefixes the double quoted path string with the backslash dir separator.
 
I am guessing that that prefix formation is very wrong and the dq should be the other side of the dir_sep char.
 
Check whether the prefix is added by Git, or by TortoiseGit.
I'm not quite familar with Tcl language, so for me, it is quite hard to debug which component cause such issue.

It may even be an attempt at backslash quoting in the tcl (different systems fighting over who gets to 'do the right thing'!).
 
I had a similar issue with a recent small patch to the gui for duplicate file entries in the resently used config variable. (it's one of the issues.. (https://public-inbox.org/git/20170122195301.17...@iee.org/ 
 
https://github.com/git-for-windows/git/issues/1014
 
Hope that helps
 
You email achieve and git issues are quite complex, sorry I even don't understand what you're discussion on those links.

Thanks.

Asmwarrior


asmwarrior

unread,
Jul 23, 2017, 7:35:53 AM7/23/17
to git-for-windows
I did some test today.
I used some debug method to see what is the actually command called when gui gui try to launch the tortoisegit by putting some
puts $xxx
In side the source file E:\Program Files\Git\mingw64\share\git-gui\lib\mergetool.tcl

Now, I see that the the %cmdline has such values:
{E:\Program Files\TortoiseGit\bin\TortoiseGitMerge.exe} -base:\"./src/CodeBlocks_wx31.cbp.BASE.cbp\" -mine:\"./src/CodeBlocks_wx31.cbp.LOCAL.cbp\" -theirs:\"./src/CodeBlocks_wx31.cbp.REMOTE.cbp\" -merged:\"src/CodeBlocks_wx31.cbp\"
This causes the error message by TortoiseGitMerge.exe.

But I finally found that if i run this command in the bash, there is no error messages from TortoiseGitMerge.exe, great!
"E:\Program Files\TortoiseGit\bin\TortoiseGitMerge.exe" -base:./src/CodeBlocks_wx31.cbp.BASE.cbp -mine:./src/CodeBlocks_wx31.cbp.LOCAL.cbp -theirs:./src/CodeBlocks_wx31.cbp.REMOTE.cbp -merged:src/CodeBlocks_wx31.cbp

So, I need to find where does those
\"
prefix comes? Any hints?

Thanks.
Asmwarrior






asmwarrior

unread,
Jul 23, 2017, 8:59:09 AM7/23/17
to git-for-windows

Good news, good news, the problem is solved.
Just add a code snippet in the file E:\Program Files\Git\mingw64\share\git-gui\lib\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]
   
}

Hope this will added to the git gui trunk, which will support using tortoisegitmerge.exe

Asmwarrior

 
Reply all
Reply to author
Forward
0 new messages