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}