Git and OpenDocument (OpenOffice.org) files

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Git and OpenDocument (OpenOffice.org) files

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:43:31

Hi,

I found a way to use git comfortably with OpenDocument files (that is,
what OpenOffice.org and Koffice produce. Text, Presentations and
Spreadsheets).

Briefly, you have to install odf2txt ( http://stosberg.net/odt2txt/ )
and the script below, together with GIT_EXTERNAL_DIFF and/or diff
drivers in .gitattributes. That give you the text diff you're used to.

Everything is documented here:

  http://www-verimag.imag.fr/~moy/opendocument/

Remarks are welcome (I'll post some remarks about Git's custom diff
driver in a separate thread).


Script available from
http://www-verimag.imag.fr/~moy/opendocument/git-oodiff and reproduced
here :

#! /bin/sh

# Script acceptable as a value for GIT_EXTERNAL_DIFF.
# For example, you can see the changes in your working tree with
# 
# $ GIT_EXTERNAL_DIFF=git-oodiff diff

echo $0 "$@"

if odt2txt "$2"  > /tmp/oodiff.$$.1  && \
    odt2txt "$5" > /tmp/oodiff.$$.2 ; then
    if diff -L "a/$1" -L "b/$1" -u /tmp/oodiff.$$.{1,2}; then
        # no text change
        if diff -q "$2" "$5"; then
            : # no change at all
        else
            echo "OpenDocument files a/$1 and b/$1 files differ (same text content)"
        fi
    fi
else
    # conversion failed. Fall back to plain diff.
    diff -L "a/$1" -L "b/$1" -u "$2" "$5"
fi

rm -f /tmp/oodiff.$$.{1,2}

Re: Git and OpenDocument (OpenOffice.org) files

From: Johannes Schindelin <hidden>
Date: 2016-06-15 22:43:31

Hi,

On Mon, 27 Aug 2007, Matthieu Moy wrote:
I found a way to use git comfortably with OpenDocument files (that is, 
what OpenOffice.org and Koffice produce. Text, Presentations and 
Spreadsheets).
Heh.  I had that problem, too.  I added an attribute "*.odt diff=odt" and 
the diff driver unpacks the zip and executes an xmldiff on the files.  
Since at times, it is more interesting to do a word based diff, depending 
on the environment variable WORDDIFF, my diff driver executes "git diff 
--color-words" instead.

Ciao,
Dscho
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help