1

Occasionally I use tools to generate code which include GUIDs. These GUIDs are generated on the fly so they are never the same and thus resulting in changes which git recognizes. Here an example:

   IXMLRequestContextType = interface(IXMLNode)
-    ['{FA84DA66-04C7-4691-BE38-491BE9C56136}']
+    ['{CB3C3662-B526-46C9-A038-8A3284BCEF73}']

Usually I discard these changes manually but this time I got a 40k+ line file with thousands of changes and I thought this process must be automatable and someone out there must have had the same problem before. While this might be true I couldn't find a solution.

I tried working with git diff --word-diff=plain --word-diff-regex="\{[A-F0-9]{8}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{12}\}" which seemed promising at first but even with the help of this answer https://stackoverflow.com/a/56090786/6308948 I couldn't (reverse) apply the patch.

Deeem2031
  • 75
  • 7
  • 1
    Generated files are typically omitted from version control altogether. We'd need to know more about your use case, but since you say you typically discard these changes I have a strong feeling that they don't belong here in the first place. – Álvaro González Jun 28 '22 at 09:45
  • The use case for this is a (Delphi) xml data binding. Generating these in a pre-build or development setup step might be possible but might add other problems. I also don't think Embarcadero (the firm behind Delphi) envisioned their [wizard](https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_the_XML_Data_Binding_Wizard) to be used this way. – Deeem2031 Jun 28 '22 at 11:29

1 Answers1

0

While writing the question I came up with a solution:

git diff -I "\{[A-F0-9]{8}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{4}\-[A-F0-9]{12}\}" | git apply --cached

This stages all the differences which contain more than just the GUIDs, so this is still staged

-    ['{837CA9B4-25A0-4C73-B608-60980131BB15}']
+    ['{279B6000-C097-4D14-A479-BC12C277300E}']
+    procedure XSDValidate;

because of the extra line. This is suboptimal but way better than nothing at all. If someone can find a solution for this too I would very much appreciate it.

Deeem2031
  • 75
  • 7