[RFC] remarks about custom diff driver

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

 



Hi,

The following is a reflexion about Git's custom diff drivers, thought
after setting up a custom diff driver for OpenDocument files.

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

Indeed, my solution has a few drawbacks: it doesn't take advantage of
git's diff engine. --color, --color-words do not work. I could use
git-diff within my script, but I can't get the argument passed on the
command-line, so I can hardcode --color for example, but not be
consistant with the rest of the diff (in case "git diff" shows the
diff between two text files and two OpenDocument files).

Also, git-diff doesn't have a -L option, so using git-diff would mean
having some a/tmp/oodiff.xzy.1 in the output, which is ugly.

Indeed, what I would have needed is a custum text converter. In my
case, I would have said something like

# ~/.gitconfig
[textconverter "odt2txt"]
	command=odt2txt

Then, in .gitattributes

*.ods textconverter=odt2txt
*.odp textconverter=odt2txt
*.odt textconverter=odt2txt

And git-diff could apply an algorithm like

if custom-diff-driver-specified
then
    custom-diff-command $1 .. $7
elif custom-textconverter-specified
    echo "Using textconverter $textconverter"
    custom-textconverter-command $file1 > $tmpfile1
    custom-textconverter-command $file2 > $tmpfile2
    use git engine on $tmpfile1 and $tmpfile2
else
    use git engine on $file1 and $file2
fi

This way, someone specifying a textconverter would automatically
benefit from all the facilities that git has for text files (all the
good stuff of git-diff, --color, --color-words, correct diff label
without bothering with -L option of diff, ...). One could imagine also
have "git-blame" work for these files, ...

One drawback: making this too much transparent, users may want to use
"git apply", or just "patch" on the generated diffs. So,
git-format-patch shouldn't use it, and that's why my pseudo-code above
displays a message "Using textconverter ...".

Any opinion? Do you think that's overkill? Anyone else have a
particuliar experience with custom diff engine?

-- 
Matthieu
-
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