‹ Version Control Setup

Integrating Simulink and Stateflow with git + GitExtensions using SimDiff

Set ToolSelector as the diff and merge tool in Git Extensions, and SimDiff opens for Simulink models.

Git is a distributed version control system. The primary interface is the command line. Git Extensions is a graphical client on top of that command line. These steps configure SimDiff for Git Extensions.

This client uses ToolSelector. ToolSelector is an ENSOFT utility that picks a configured tool from the input arguments, for example the file type. The ToolSelector User Guide.pdf is in the ToolSelector directory. By default that directory is C:\Program Files\EnSoft\SimDiff\utils\toolselector. If you use a SimDiff version older than 2020a.2, the directory is C:\Program Files\EnSoft\SimDiff\utils\toolselector-20120215-1803.

Configuration

  1. Download gitExtensions-simdiff.zip.
  2. Copy the extracted files to your ToolSelector directory (by default, C:\Program Files\EnSoft\SimDiff\utils\toolselector).
  3. Configure Git Extensions’ external diff and merge tools:
  • Open Git Extensions.
  • Click Tools, then Settings.
  • Enter the following in the Git Config section under the Git Extensions configuration, as in the picture below.

Mergetool: simdiff

Path to mergetool: C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe

Mergetool command:

"C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe" -profile=3way-merge $PWD $MERGED $REMOTE $BASE $LOCAL

Difftool: simdiff

Path to difftool: C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe

Difftool command:

"C:/Program Files/EnSoft/SimDiff/utils/toolselector/toolselector.exe" -profile=2way $PWD $LOCAL $REMOTE
Git Extensions Settings, Git Config, with Mergetool and Difftool set to simdiff and the ToolSelector commands for profile=3way-merge and profile=2way outlined in red

Notes

  • If SimDiff and ToolSelector are not in their default locations, change the paths in step 3.
  • If ToolSelector is not in its default location inside the SimDiff directory, update simdiff-cd.bat with the correct absolute or relative path to simdiff4.exe.
  • Use a 3-way diff as part of the merge. A 3-way diff shows what differs between two versions and which model each change came from. 3-way diff is included in every edition of SimDiff.

Usage

To see the differences between two versions of a model, click Open with difftool, then the option you want (for example First to Second). Git Extensions opens SimDiff. The picture shows this for an unstaged file compared with the copy in the repository.

Git Extensions file menu on aero_radmod.mdl, with Open with difftool and First to Second highlighted

SimDiff also launches when Git Extensions finds a merge conflict. The steps below merge a branch into the branch that is checked out. Right-click the branch to merge and follow the pictures.

Git Extensions branch menu on dev, with Merge into current branch and then dev marked 1Git Extensions Merge branches dialog merging dev into master, with the Merge button marked 2Git Extensions process window showing a content conflict in aero_radmod.mdl, with OK marked 3Git Extensions Merge conflicts dialog asking to solve conflicts now, with Yes marked 4

In this dialog, click Start mergetool to open SimDiff and merge the changes.

Git Extensions Resolve merge conflicts dialog with aero_radmod.mdl selected and Start mergetool marked 5SimDiff Team merging aero_radmod, with Actual Speed selected and its Value 400 in the output and base and 500 in the right model, marked 6

Use SimDiff to merge the changes. When you are done, save the model from the Simulink window and close SimDiff. The next dialog appears.

Git Extensions Commit dialog saying all merge conflicts are resolved, with Yes marked 7Git Extensions Commit to master window with aero_radmod.mdl staged and the Commit button marked 8

Commit the merged model.

Using another client? See Version Control Setup.