Re: Git and OpenDocument (OpenOffice.org) files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Matthieu Moy <Matthieu.Moy@xxxxxxx> writes:
>
>> Remarks are welcome (I'll post some remarks about Git's custom diff
>> driver in a separate thread).
>
> Good.
>
> I think creation/deletion will get /dev/null as the temporary
> file name, so as long as odt2txt knows how to deal with
> /dev/null you would not have to worry much about them.

But odt2txt doesn't know how to deal with /dev/null. New version of
git-oodiff that manages it correctly online and below.

> You might want to be careful about unmerged paths, though.  They
> will not get anything other than $1 (name).

I don't know how to manage this correctly, so I just display a message
"Unmerged path $1" and die.

> You would probably not care about the mode changes for oo
> documents, but they are available as $4 and $6 respectively, if
> you care.

I don't care, but the new version still manages them ;-).

All this convince me that the ability to provide a plaintext converter
(see the other thread I started) would make it much simpler to write
such kind of things. The mode change, for example, could be managed
automatically by git, I wouldn't need to write my own 'echo "new
mode ..."'.

Thanks for the advices.

-- 
Matthieu

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

#! /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

convert_to_txt ()
{
    if [ x"$1" = x"/dev/null" ]; then
        printf "" > /tmp/oodiff.$$."$2"
        eval "label$2=/dev/null/"
    else
        odt2txt "$1" > /tmp/oodiff.$$."$2" 2>/dev/null
    fi
}

echo $(basename $0) "$2" "$5"

if [ "$#" = "1" ]; then
    echo "Unmerged path $1"
    exit 0
fi

if   [ x"$4" = x"." ]; then
    echo "new file mode $7"
elif [ x"$7" = x"." ]; then
    echo "deleted file mode $4"
elif [ x"$4" != x"$7" ]; then
    echo "old mode $4"
    echo "new mode $7"
fi

label1="a/$1"
label2="a/$1"

if convert_to_txt "$2" "1" &&
    convert_to_txt "$5" "2" ; then
    if diff -L "$label1" -L "$label2" -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 "$label1" -L "$label2" -u "$2" "$5"
fi

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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux