At work I use git as a version control system and Dymola for modeling and simulation.
One major Issue I have is that once I touch or by mistake move a connection (more exactly the position of a part of the connecting wire) in a diagram without changing any parameters -which usually happens when discussing or explaining by showing the diagram to colleagues- git consider this as a version change or change in the file. At least the real change is 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 the 2nd 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 therefore is: How can I prevent such an unnecessary "change" in the code on either side: git or Dymola?
The graphical part of your model also has to be stored somewhere, and the place Modelica uses are so called annotations. Every model, instance of a model and also every connection has such annotations. The graphics do not influence the "pyhsical" behavior, but they are still important for end user convenience.
Now, if you edit some icon or connection (or, anything else) from the GUI, this change will be reflected in the code. And once you click the save button, the file will be written to disk and git will notice that the code has changed. Some of these changes might be on purpose (some people invest a lot of time in nice looking connections), while other changes might not be important. There is absolutely no way how a version control system can decide what you consider relevant, that decision is up to you. You can always decide NOT to save your changes (in Dymola, choose the Save None
button).
In addition to the changes that you are responsible for, your tool (e.g. Dymola) might try to be smart and do some auto-formatting. There are users that consider Dymolas behavior too intrusive (e.g. breaking lines, inserting whitespace, adding irrelevant annotations, moving comments around). Sadly, there is not much you can do here, except of course stopping to use Dymola as an editor (and instead only use it as a simulation tool), or you can use cleanup tool like ttws (trim-trailing-white-space). As far as I know, Dymola does not move around your icons, so the example you showed was not introdced by Dymola.
Now, second part of your question. If for some reason you have clicked the save button, git (and any other good version control system) allows you to revert your changes, or part of your changes, before commiting (or after commiting, but then things get more complicated). Also, you do not have to push all your commits to the central repository. The exact workflow will depend on which git client you use and whether you use a graphical user interface or the command line. Which one do you use?
Below is a screenshot of the GitExtensions commit dialog (this image is the main reason for writing an answer instead of a comment):
There are many tutorials and books available on how to use git, you probably want to read these, as well as the manual for the git client of your choice. Or, you simply do not click the save button when there is nothing you want to save.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With