git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] remarks about custom diff driver
@ 2007-08-27 10:36 Matthieu Moy
  2007-08-27 10:45 ` Jeff King
  2007-08-27 23:29 ` [RFC][PATCH] " Matthieu Moy
  0 siblings, 2 replies; 3+ messages in thread
From: Matthieu Moy @ 2007-08-27 10:36 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-08-27 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-27 10:36 [RFC] remarks about custom diff driver Matthieu Moy
2007-08-27 10:45 ` Jeff King
2007-08-27 23:29 ` [RFC][PATCH] " Matthieu Moy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).