Unity Smart Merge (UnityYAMLMerge.exe): how to configure vsDiffMerge.exe in the mergespecfile.txt?
Hello,
I am using GitHub as my repository and I want to use vsDiffMerge.exe as my fallback merge tool. I tried to configure it in mergespecfile.txt as:
* use "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe" "$LOCAL" "$REMOTE" "$BASE" "$MERGED" //m
and as:
* use "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe" "%r" "%l" "%b" "%d"
The first command does not work at all. The second command does just the diff (not the merge operation - more information here) and I tried to add the //m in the end, but same thing, it just does the diff.
In SourceTree, I have the UnityYAMLMerge.exe correctly configured:
Merge Tool = Custom
Diff command = C:\Program Files\Unity\Editor\Data\Tools\UnityYAMLMerge.exe
Arguments = merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
The YAML merge (scene and prefabs) works well, but the problem is to launch the fallback tool for scripts.
By the way, if I configure the vsDiffMerge.exe directly in SourceTree like below it works well for the scripts (but for YAML not of course - I want to use the UnityYAMLMerge.exe for prefabs and scenes as the default merge tool, not vsDiffMerge.exe):
Merge Tool = Custom
Diff command = C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsdiffmerge.exe
Arguments = "$LOCAL" "$REMOTE" "$BASE" "$MERGED" //m
Nowadays, I keep switching between those configurations in SourceTree (when I need to merge scripts I put vsDiffMerge.exe, when I need to merge YAML I put UnityYAMLMerge.exe), but this is not productive and the mergespecfile.txt should work.
By the way, I could configured successfully p4Merge in mergespecfile.txt, but I prefer vsDiffMerge.exe :)
Answer by andrasgabor · Oct 15, 2018 at 05:58 PM
I created a proxy script as:
o:\git\tools\vsmerge.bat
Content:
"c:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" /m "%1" "%2" "%3" "%4"
I am invoking this from mergefilespec.txt:
* use "o:\git\tools\vsmerge.bat" "%r" "%l" "%b" "%d"
It did not work without the proxy script. This way though the merge button works in the team explorer from VS for code.
Nice workaround. Here's my attempt at TortoiseGit$$anonymous$$erge:
* use "c:\util\yamlmerge-tortoisemerge.bat" "%b" "%l" "%r" "%d"
"C:\Program Files\TortoiseGit\bin\TortoiseGit$$anonymous$$erge.exe" /base:%1 /$$anonymous$$e:%2 /theirs:%3 /merged:%4
Answer by guiquadros · Mar 29, 2017 at 06:23 PM
I found a solution that worked for me (although I could not correctly configure the mergespecfile.txt file to use vsDiffMerge.exe):
in .gitconfig I added an addition entry:
[mergetool "vs"]
cmd = 'C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE $BASE $MERGED //m
trustExitCode = true
And in the console I run:
For .prefab and .unity:
git mergetool
For .cs:
git mergetool --tool=vs
If I need to run for a specific file:
git mergetool --tool=vs *<file_name>.cs
Here is my whole merge/diff configuration in the .gitconfig file:
[mergetool "vs"]
cmd = 'C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE $BASE $MERGED //m
trustExitCode = true
[difftool "sourcetree"]
cmd = 'C:/Program Files (x86)/Microsoft Visual Studio 12.0/Common7/IDE/vsdiffmerge.exe' $LOCAL $REMOTE Source Target //t
[mergetool "sourcetree"]
cmd = 'C:/Program Files/Unity5.5.1f1/Editor/Data/Tools/UnityYAMLMerge.exe' merge -p $BASE $REMOTE $LOCAL $MERGED
trustExitCode = false
keepTemporaries = true
keepBackup = false
[merge]
tool = sourcetree
[diff]
tool = sourcetree
[core]
autocrlf = true
So, this solved my merge issues with the .cs files (which was my main merge configuration problem). But my fallback tool in the mergespecfile.txt is still p4merge (which does not bother me so much to solve unsolved scene and prefab conflicts the Unity Smart merge could not handle):
unity use "C:\Program Files\Perforce\p4merge.exe" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
prefab use "C:\Program Files\Perforce\p4merge.exe" "$BASE" "$REMOTE" "$LOCAL" "$MERGED"
# Perforce merge
* use "%programs%\Perforce\p4merge.exe" "%b" "%l" "%r" "%d"
* use "%programs%/p4merge.app/Contents/Resources/launchp4merge" "%b" "%l" "%r" "%d"
If anyone knows how to configure the mergespecfile.txt to work with the vsDiffMerge.exe as the fallback tool I would like to see the solution.
Hey, I know this post is more than a year old, but I'll take my chances. I'm currently experiencing the very same issue - cannot configure vsDiff$$anonymous$$erge to act as a fallback tool properly. Did you get it solved by any chance?
Hello @TuRtoise, the answer is no. I still running “git mergetool --tool=vs myFile.cs” for code merges (.cs files) and “git mergetool myFile.prefab” for prefabs and scenes. When the Smart $$anonymous$$erge fails to merge a prefab or scene another fallback tool (not VS) is called to solve the conflict (I was using p4merge, but now I am trying Win$$anonymous$$erge). So I am still unable to use Visual Studio as a fallback tool for the Smart $$anonymous$$erge.
The nice thing with Win$$anonymous$$erge is that it's command line will accept dashes ins$$anonymous$$d of forward slashes which gets around the YA$$anonymous$$L$$anonymous$$erge issue. Unfortunately I've not yet figured out the right set of command line options.