Merge Conflicts, "Relationship Issues"
A merge operation merges the contents of two branches which have a common ancestor but have received different changes. Targeted merging of branches is mainly done in the Git Branches view using the Merge command. A merge operation is also included in a pull action.
Different states of the source and target branches are detected during the merge operation and are called a conflict. An unpermitted project structure resulting from merging is identified as a "relationship issue". Depending on the set option, CODESYS Git tries to automatically resolve these conflicts whenever possible, or this resolution is left to the user.
After the conflict is resolved, CODESYS Git always tries to Resynchronize (re-read the project from the project storage). This is done by closing the project which is open in CODESYS and creating a new one from the storage.
CODESYS Git distinguishes between two types of problems to be resolved which can occur while merging:
Conflicts: Pure Git conflicts: One or more objects received competing changes. It can be different changes in the contents of an object.
The basic "merge conflict strategy" is set in the Git Merge Options in the Git Branches view. Depending on this setting, either an automatic conflict resolution runs whenever possible, a basic acceptance action is taken in a specific direction, or the conflicts are handled manually.
In case of manual conflict resolution, the conflicting objects are displayed as such in the Status & Staging view. Double-clicking a conflicting object opens a comparison view. In the comparison view, the changes originating from the two branches are displayed side by side. You can clean up differences in the contents by specifically accepting them. If they are purely namespace conflicts, then you need to resolve them by renaming or deleting in the project tree. Click “Apply” to resolve the conflict. After that, the previously conflicted object is automatically moved to the “Staged Changes” area.
“Relationship Issues": Competing changes have resulted in an invalid project structure in CODESYS, which cannot be handled by the Git merge function. Changes may have been made externally in the file system with external tools. Or a concurrent creation of an object of the same type and/or the same name was committed from different branches, and this object is then located in the same namespace in the CODESYS project. This is not allowed in a CODESYS project. Or an invalid father/child object relationship has occurred. Another possibility is that relationship issues originate from previous merges, where they were deliberately ignored in order to be able to continue working for the time being.
For example, the situation happens that two alarm configurations are inserted below one device, which is not allowed.
The user has to manually correct the project structure using the available means (merging one object into another, deleting, renaming, or moving) to get a consistent project again.
Important
As of version 1.2.0.0, a project can also be processed further with existing relationship issues (ignore). Attention: In such a case, changes to the project are discarded by a later resynchronization. Reason: The resynchronization operation loads the project version from the file system which was saved before the relationship issue was ignored.
In the Status & Staging view, you as a user can check and edit a conflict as follows:
Helpful commands are available in the context menu of a conflicting object. The current selection depends on the situation:
Show all affected objects / Show this object: The objects or object will be highlighted in the Devices view of the project.
Resolve using theirs: The state of the source branch is applied.
Resolve using ours: The state of the target branch is applied.
Resolve automatically: CODESYS Git tries to consolidate the changes itself.
Mark as resolved: The object which currently exists in the project is applied and considered to be the resolution of the conflict. The corresponding object has been staged.
Ignore Relationship Issue: The relationship issue is ignored until the next resynchronization. This can be useful when you only want to be able to continue working on a project and the conflict does not matter for this.
Double-clicking a conflicting object opens the comparison view of source and target branch contents. In the case of competing contents, the contents can be applied from one branch to the other as you want.
In the Messages view, you can double-click an error message for a conflict in order to open the affected object.