Versioning with git with Dymola / Modelica

In my work, I use git as a version control system and Dymola for modeling and modeling.

One of the main problems that I have is that when I touch or mistakenly move the connection (more precisely, the position of the part of the connecting wire) on the diagram without changing any parameters, which usually happens when discussing or explaining, the diagram for fellow git consider this a change or a change in the file. At least a real change occurs in some auto-generated Modelica annotations, for example:

connect(TT_1.T, Controller.y[1]) annotation (Line( points={{48,-20},{48,40},{-22.5,40},{-22.5,29.25}}, color={0,0,127}, smooth=Smooth.None)); 

changed to (compare 2 lines)

  connect(TT_1.T, Controller.y[1]) annotation (Line( points={{48,-20},{48,38},{-22.5,38},{-22.5,29.25}}, color={0,0,127}, smooth=Smooth.None)); 

My question is: How can I prevent such an unnecessary "change" in the code on both sides: git or Dymola?

+6
source share
1 answer

The graphic part of your model should also be stored somewhere, and the Modelica place uses so-called annotations. Each model, example model, and also each connection have such annotations. The graphics do not affect the pyhsical behavior, but they are still important for the convenience of end users.
Now, if you are editing any icon or connection (or anything else) from the graphical user interface, this change will be reflected in the code. And as soon as you press the save button, the file will be written to disk, and git will notice that the code has changed. Some of these changes can be targeted (some people invest a lot of time in beautiful applications), while other changes may not be important. There is absolutely no way how a version control system can decide what you think is relevant; this decision is up to you. You can always decide NOT to save your changes (in Dymola, select the Save None button).

In addition to the changes you are responsible for, your tool (e.g. Dymola) may try to be smart and do some automatic formatting. There are users who find Dymolas behavior too intrusive (for example, line breaks, inserting spaces, adding irrelevant annotations, moving comments around). Unfortunately, little can be done here, except, of course, to stop using Dymola as an editor (and instead use it only as a modeling tool), or you can use a cleaning tool such as ttws (trim-trailing-white-space ), As far as I know, Dymola does not navigate your icons, so the example you showed was not introduced by Dymola.

Now, the second part of your question. If for some reason you clicked the save button, git (and any other good version control system) allows you to revert your changes or part of your changes before committing (or after committing, but then the situation becomes more complicated), In addition, you don’t you need to push all your commits to the central repository. The exact workflow will depend on which git client you are using and whether you are using a graphical user interface or command line. Which one are you using?
Below is a screenshot of the GitExtensions commit dialog (this image is the main reason for writing the answer instead of the comment):

GitExtensions Commit Stage Revert dialog

  • In the upper left you see all the files in which git noticed a change, here you can return entire files.
  • In the bottom left you see an intermediate area. Only files in the staging area will be part of your commit.
  • At the top right, you see diff and a context menu that allows you to reset single lines of code.
  • In the lower right corner, enter the text of the commit message.

There are many tutorials and books on how to use git, you will probably want to read them, as well as a guide for the git client of your choice. Or you just don’t press the save button when you don’t want to save anything.

+3
source

All Articles