Unity Hub, Smart Merge and Gitconfig portability

In the old days, we have one Unity install on the machine, and our gitconfig for UnityYAMLMerge is as simple as following:

[merge]
tool = unityyamlmerge

[mergetool "unityyamlmerge"]
trustExitCode = false
cmd = '/Applications/Unity/Unity.app/Contents/Tools/UnityYAMLMerge' merge -p "$BASE" "$REMOTE" "$LOCAL" "$MERGED"

Assuming all your engineers are on macOS, there won’t be any issue.

Nowadays Unity is installed with Unity Hub, which means the UnityYAMLMerge path kept changing with each release. Such that gitconfig has to keep up, unless given a way to detect Unity install path.

And of course you run into problems when one user is using Unity Hub and the other is not.

I don’t know the best way to tackle this, but my workaround was to copy UnityYAMLMerge into a custom directory and refers to it. Doing so isn’t cross platform neither, and worse, UnityYAMLMerge program doesn’t output version information, so it’s impossible for me to know when I need to update it next.

To workaround this, GitHub for Unity has do away with a static gitconfig all together, and make it a dynamic configuration. I doubt everyone has the luxury / incentive of using GitHub tool. So a proper solution is needed for other git users.

There are a few possible solutions:

  • Unity Hub can distribute this tool separately, so the path is fixed.
  • Unity could update documentation to guide people to setup gitconfig in another way.
  • Unity could integrate this tool with popular code editor as extensions.

I don’t know how other teams solve this issue, so suggestions welcomed.

(Personally, I seldom run into merge conflict, mostly because I am usually the sole programmer on a project; and in my case I didn’t notice the path was wrong in my gitconfig for over 6 months…)

1 Like

One possible solution is to create a trampoline application which parses the Unity Hub defaultEditor.json configuration to find the current preferred editor and forwards the call there. You can then keep this tool in a static location and it doesn’t need to get updated unless Unity changes where they store the information about current preferred editor.