3

As OpenXML is basically XML files in a zip archive, I'd like to know if Git can handle OpenXML documents for version control and merging operations and diff comparison. thanks

mak
  • 1,384
  • 1
  • 13
  • 21

2 Answers2

4

You can take the following approach with any zipped file format: have git unzip the file before storing it in the repo, and then rezip it again before checking it out. Then text diffing works because whatever's in the repo is mostly plain text.

People are definitely using this approach: see Uncompress OpenOffice files for better storage in version control

Community
  • 1
  • 1
Yawar
  • 11,272
  • 4
  • 48
  • 80
1

Enabling diff for non-text files in Git is achieved with Git Attributes.

Chapter 7.2 Customizing Git - Git Attributes in the Pro Git book describes how to configure .gitattributes. It gives a specific example (odt-to-txt) of how to do so for OpenDocument files. Since OpenDocument is also a zipped xml format, that example should be reasonably straightforward to modify for OpenXML.

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
  • Are you certain that that enables *merging*? My reading of it suggests that it's a filter applied at the time you ask git for a diff. That is, the revision history is still made up of the *binary* files and text-based merging is still not possible; the filtering just allows you to generate a human readable diff but not to apply it. (ie. it's only a 'diff' in a somewhat sloppy sense) – kampu Jun 05 '13 at 12:56
  • @kampu No, now that you mention it, I am not sure it enables merging, so I removed that from my answer. – Klas Mellbourn Jun 05 '13 at 16:55