Working with Command Line Git

Successfully working with Model RealTime models using Git requires proper configuration of merge operations. This section will provide a detailed guide on how to achieve this integration, ensuring that your Git workflows are compatible with Model RealTime.

Note: If the merge integration is not in place, Git merge commands may inadvertently apply a default text-based merge, leading to potential corruption of Model RealTime models.

In the following sections, we will delve deeper into the technical details of:

Invocation from Command Line

The integration of Model RealTime into Git command line handling is primarily done using the Model RealTime command line tool for compare/merge. This is implemented by a Java application called cmcmdline.jar that is available in the Model RealTime installation. It's located in the plugin folder for the com.ibm.xtools.comparemerge.team plugin. For example (the part in boldface depends on the installed version of Model RealTime):

<install-dir>\plugins\com.ibm.xtools.comparemerge.team_7.60.100.v20180618_1038\utm

The details of this command line application are given in the chapter "Command Line Tool for Compare/Merge" in "Comparing and Merging Models". See also the reference guides for the command line tools available from the Model RealTime Compare/Merge documentation page. In this document, we will only cover what is needed for Git integration.

Merge Integration

Git provides a way to customize how it handles merge operations for different file types. This is done by defining "merge drivers." These drivers are essentially instructions for Git on how to handle specific file types during a merge. A description on how this is done can be found at https://git-scm.com/docs/gitattributes. See in particular the section "Defining a custom merge driver".

The following is needed:

Let's look at an example config definition defining merge for the three most common types of files handled by Model RealTime (.emx, .emf, and .tc). As you can see, the only difference between the drivers is that the extension is passed to the command line tool using the "-ext" argument for emx/efx files. This is shown in bold below. The installation-specific path to cmcmdline.jar that you need to modify (see above) is shown in bold and underlined:

[merge "rsarteemx"]
  name = Model RealTime EMX merge driver
  driver = java -cp **<path-to-cmcmdline-tool>** /cmcmdline.jar com.ibm.xtools.comparemerge.cmcmdline.CMTool merge -ext=emx -ancestor %O -left %A -right %B -out %A

[merge "rsarteefx"]
  name = Model RealTime EFX merge driver
  driver = java -cp **<path-to-cmcmdline-tool>** /cmcmdline.jar com.ibm.xtools.comparemerge.cmcmdline.CMTool merge -ext=efx -ancestor %O -left %A -right %B -out %A

[merge "rsartetc"]
  name = Model RealTime TC merge driver
  driver = java -cp **<path-to-cmcmdline-tool>** /cmcmdline.jar com.ibm.xtools.comparemerge.cmcmdline.CMTool merge -ancestor %O -left %A -right %B -out %A

An example definition from a Git attributes file:

*.emx merge=rsarteemx
*.efx merge=rsarteefx
*.tc merge=rsartetc

When these (or similar) definitions are done, all command line Git commands that trigger a merge invocation will correctly handle Model RealTime model files. Note, however, that this will only trigger a file-by-file merge. To invoke a logical model merge or a closure merge, either use the Model RealTime graphical user interface or call the command line application cmcmdline.jar directly as described in the section "Command Line Tool for Compare/Merge" in "Comparing and Merging Models".

Also note that this integration only handles "merge", not the conflict resolution that requires a "merge tool" integration. Currently, we recommend the usage of the graphical user interface in Model RealTime to handle conflict resolution.

Git Hooks

Git allows various hooks to be associated with various actions. In general, this works fine together with Model RealTime, but there is one exception: Scripts that require user interaction, for example, asking for confirmation of some action, will not work from the Model RealTime user interface. From a user's point of view, it will appear as if the tool hangs when this happens. A typical example is a pre-commit hook that asks for user input. This will, for example, be triggered when pressing the "Commit" button in the Git Staging View, and the tool will appear to hang.