2

I stumbled upon an old blog post suggesting this, unfortunately only as an unimplemented idea. Has this been done meanwhile / how can it be achieved? (I heard TortoiseGit might do this, but I'm running Linux)

An alternative could also be the re-zip approach mentioned here, suggesting a git filter which tracks the uncompressed OpenDocuments and recompresses them on checkout, which would offer the option to at least merge (and diff) the xml contents instead of binary garbage (or the lossy odt2txt), however I didn't find any updates on this approach either, the last post about this warns about potential flaws in this approach.

Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221
  • 2
    Another option, at least with more recent versions of Open/LibreOffice, is to not save to the compressed file type - in the Save As dialog, you can select "Flat XML" (`.fods` for spreadsheets, `.fodt` for documents, etc...). The files will be considerably larger, but will merge much more reasonably, as it's roughly equivalant to the re-zip approach without many of the complications. – twalberg Aug 03 '12 at 14:54
  • @twalberg thanks for that information. Together with the `--convert-to` [command line parameter](http://help.libreoffice.org/Common/Starting_the_Software_With_Parameters) that filter could be implemented, assuming fod* <-> od* is revertible (up to irrelevant changes). [If only that wouldn't require Office to be closed...](https://bugs.freedesktop.org/show_bug.cgi?id=37531) – Tobias Kienzler Aug 03 '12 at 15:16
  • (note to self: that bug can be worked around via `-env:UserInstallation=file:///some/path`) – Tobias Kienzler Aug 03 '12 at 15:38
  • @twalberg [I tried automating this](http://stackoverflow.com/a/11799390/321973), which unfortunately doesn't work fully due to some meta-data. But I'll simply instruct all users (that is, currently, me) to work directly with `.fod?` files. – Tobias Kienzler Aug 03 '12 at 16:11
  • I've never tried automating it, as any spreadsheets, etc. I've wanted to track, I just save them that way to begin with. Haven't had to deal with converting an existing body of work, which, from your other comments, seems it isn't quite a smooth process... – twalberg Aug 03 '12 at 17:07
  • related question: [Uncompress OpenOffice files for better storage in version control](http://stackoverflow.com/q/975167/321973) – Tobias Kienzler Sep 28 '12 at 06:15

2 Answers2

0

You can try it, and you will let us know. From what I remember, merge tools are configured to have 4 inputs, so you will have to configure Git to use it as a merge tool.

You have to add a couple lines in the config file, merge.tool, mergetool.<tool>.path and mergetool.<tool>.cmd

http://www.kernel.org/pub/software/scm/git/docs/git-config.html (search for "merge.tool" in the page)

http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html

Hope it helps

Vince
  • 1,570
  • 3
  • 27
  • 48
  • It is not of highest priority to me, which is why I was hoping someone has tried already... But yes, _if_ (probably rather _when_) I do this myself, I will post an answer here (Damn your Jedi trickery :-P ) – Tobias Kienzler Aug 03 '12 at 13:25
0

Inspired by twalberg's comment I wrote to simple scripts od2fod and fod2od which use the --convert-to parameter of Libre/OpenOffice in order to convert the zipped xml into an uncompressed one and vice versa. Due to a bug denying CLI actions when the LibreOffice GUI is running I had to write the workaround loInstance:

#!/bin/bash
tmpdir=$(mktemp -d)
cp -rf ~/.libreoffice $tmpdir
soffice -env:UserInstallation=file://$tmpdir $@
rm -rf $tmpdir

od2fod and fod2od are simple, though:

#!/bin/bash
loInstance --headless --convert-to f${1#*.} $1

and

#!/bin/bash
loInstance --headless --convert-to ${1#*.f} $1

One could now setup a clean and smudge filter in .gitattributes, however I notice LO keeps track of superfluous meta-data which brakes the clean-smudge circle. So for now this can only be used as a imperfect textconv tool for git-diff...

Community
  • 1
  • 1
Tobias Kienzler
  • 25,759
  • 22
  • 127
  • 221