Search Unity

Visual Studio as fallback mergetool doesn't work properly

Discussion in 'Code Editors & IDEs' started by Deleted User, Jun 10, 2018.

  1. Deleted User

    Deleted User

    Guest

    I'm trying to use Visual Studio's 'vsDiffMerge' as a fallback tool for Unity's 'UnityYAMLMerge', so I can manually handle some of the more complicated merge conflicts. I'm using git (msys2), by the way.

    The problem is, whenever I run 'git mergetool', VS opens its difftool instead of a mergetool.

    Here are the steps I've gone through so far:
    1) Changed Unity's Editor settings to: 'Visible Meta Files' and 'Force Text'
    2) Added 'UnityYAMLMerge' as a default mergetool inside git's config file as shown in Unity Docs:
    3) Following advice given here , modified 'mergespecfile.txt' in a following manner:

    unity use "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" "%r" "%l" "%b" "%d" /m

    prefab use "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" "%r" "%l" "%b" "%d" /m

    * use "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" "%r" "%l" "%b" "%d" /m


    4) Tried fiddling with the slashes/backslashes and with the order of switches/arguments, nothing really helped.

    Once again, theoretically there is no explicit "error" showing - VS merge tools simply doesn't open. Instead I'm stuck with the built-in difftool, which is not even half as helpful.

    As a side note - I tried 2 additional things:
    1) Running the merge operation from VS' git plugin - the result being more or less the same.
    2) When notified about a conflict taking place, I explicitly used vsDiffMerge with a following path setting:

    cmd = \"C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\Common7\\IDE\\CommonExtensions\\Microsoft\\TeamFoundation\\Team Explorer\\vsDiffMerge.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\" //m

    And it actually worked - VS' Mergetool opened properly.

    Now the thing is - why opening it manually works and re-directing to it via UnityYAMLMerge doesn't and what can I do to fix it?
     
    Last edited by a moderator: Jun 10, 2018
  2. Deleted User

    Deleted User

    Guest

    Okay so it turns out that the only (probably) problem is that vsDiffMerge switches are not executed in any way when specified in 'mergespecfile'.

    As a result:
    unity use "path/to/the/tool/vsDiffMerge.exe" %l %r %b %d /m
    is treated equally to:
    unity use "path/to/the/tool/vsDiffMerge.exe" %l %r
    And that, what a surprise, is supposed to (and well - does it) open the diff tool for files %l and %r.

    Having that said, it remains a mystery to me how to pass the "/m" switch via 'mergespecfile'.
     
  3. HeintzY

    HeintzY

    Joined:
    Sep 18, 2021
    Posts:
    1
    I had the same problem, but I finally found a solution.

    It seems like the problem was the correct placement of the /m in the mergespecfile.txt

    Here are the settings that worked for me, using Windows with Unity version 2020.3.18f1:


    1) Unity settings

    Edit>Project Settings>Version Control>Mode>Visible Meta Files

    Edit>Project Settings>Editor>Asset Serialization>Mode>Force Text


    2) Setup UnityYAMLMerge as a merge tool in git

    git config --add merge.tool unityyamlmerge

    git config --add mergetool.keepBackup false

    git config --add mergetool.unityyamlmerge.trustExitCode false

    git config --add mergetool.unityyamlmerge.cmd '"C:\Program Files\Unity\Hub\Editor\2020.3.18f1\Editor\Data\Tools\UnityYAMLMerge.exe" merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"'

    This should result in the following local .config settings
    [merge]
    tool = unityyamlmerge
    [mergetool]
    keepBackup = false
    [mergetool "unityyamlmerge"]
    trustExitCode = false
    cmd = \"C:\\Program Files\\Unity\\Hub\\Editor\\2020.3.18f1\\Editor\\Data\\Tools\\UnityYAMLMerge.exe\" merge -p \"$BASE\" \"$REMOTE\" \"$LOCAL\" \"$MERGED\"


    3) Setup the mergespecfile.txt for vsDiffMerge



    unity use "%programs%\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" /m "%l" "%r" "%b" "%d"
    prefab use "%programs%\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" /m "%l" "%r" "%b" "%d"

    #
    # Default fallbacks for unknown files. First tool found is used.
    #

    # Windows vsDiffMerge
    * use "%programs%\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\vsDiffMerge.exe" /m "%l" "%r" "%b" "%d"




    If it does not let you modify the file, “Right Click”>Properties>Security>Edit and allow Users to modify the file.


    I hope it helps!
     
    Last edited: Sep 20, 2022