gitgit-mergeopendocumentmergetool

Can the LibreOffice / OpenOffice merge tool be used as `git-mergetool`?


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.


Solution

  • 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...