Inkscape re-ordering style attribute values randomly
Summary
I have large Inkscape SVG files and was hoping to be able to use a VCS (such as git) in order to track incremental changes to the SVG files.
Unfortunately, Inkscape seems to be re-writing nearly every tag within the document, even when a change is only made to a single object, and in the process of re-writing all these tags it is changing the order of the attributes (even though none of the data for these attributes actually changes).
Thus the VCS believes that the majority of the file has changed (because it is, of course, too dumb to understand that attribute ordering in XML/SVG is irrelevant).
Alas, the re-ordering behaviour (whether a bug or not?) makes putting Inkscape SVG files into a VCS utterly pointless as it is impossible to actually tell what has changed (rather than just been re-ordered) in git diffs, etc
As a note, I feel I should mention that I was able to trigger this behaviour just cutting an object from one layer and pasting it (in place) into another layer. The diff was much more than just the removal of the object tag rect from one layer and its insertion into another.
This is partially tracked in #1179 (closed)
However, even with the workaround given, the style attribute stills gets reordered
- <rect style="fill:#b4754b;fill-opacity:1;fill-rule:nonzero;stroke:#000000;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline;enable-background:new" id="buildingrect64-2-2-99-5-5-2-1" width="24.008482" height="23.699667" x="-674.0014" y="-681.63464" inkscape:label="#rect" transform="matrix(-0.99303745,0.11779911,-0.11779911,-0.99303745,0,0)">
+ <rect style="display:inline;fill:#b4754b;fill-opacity:1;fill-rule:nonzero;stroke:black;stroke-width:2;stroke-linecap:square;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;enable-background:new" id="buildingrect64-2-2-99-5-5-2-1" width="24.008482" height="23.699667" x="-674.0014" y="-681.63464" inkscape:label="#rect" transform="rotate(173.2349)">
Steps to reproduce:
- Take an SVG that has multiple objects tags with multiple attributes such as id, style, offset, etc
- Commit said SVG into a VCS such as git
- Open the SVG in Inkscape and move 1 of the objects around or to a different layer
- Save the SVG
- Use
git diff
or some other VCS equivalent to see what has changed in the file
part of this is tracked in #1179 (closed), so this issue is focused on the changes to the style attribute. One way to see this change is to
- Use workaround in #1179 (closed)
- Create a rectangle.
- Change color using Fill and Stroke Dialog (sets fill-opacity).
- Save
- move the rectangle (just tap once with an arrow key)
- Save as a separate file.
- Compare the files
What happened?
Inkscape rewrote the file and re-ordered the tag attributes for objects that I had not selected, moved, resized, or altered in any other way. Thus the diff doesn't show just what the user actually changed but also shows all the unnecessary orderings.
With the workaround applied, the second set of steps still results in Fill opacity being moved from the end of the style attribute to the start.
What should have happened?
Inkscape should either not randomly re-order tag attributes when saving for objects that have not been changed by the user since last save, or Inkscape should chose a fixed ordering (possibly alphabetical?) for tag attributes and always write the attributes in this fixed order.
Version Info:
- Inkscape Version: 1.0 (4035a4fb49, 2020-05-01)
- Operating System: Windows 10
- Operating System version: 10.0.18362