]> git.ipfire.org Git - thirdparty/git.git/commit - diff.c
refactor userdiff textconv code
authorJeff King <peff@peff.net>
Sun, 26 Oct 2008 04:44:53 +0000 (00:44 -0400)
committerJunio C Hamano <gitster@pobox.com>
Sun, 26 Oct 2008 21:09:48 +0000 (14:09 -0700)
commit04427ac8483f61dcb01a48c78a821f5042c88195
tree90c925a7bd0d756d86bfa092ca779b5834b5554f
parentdf5e91fc2c95e051744ec9b9de66869d2b323037
refactor userdiff textconv code

The original implementation of textconv put the conversion
into fill_mmfile. This was a bad idea for a number of
reasons:

 - it made the semantics of fill_mmfile unclear. In some
   cases, it was allocating data (if a text conversion
   occurred), and in some cases not (if we could use the
   data directly from the filespec). But the caller had
   no idea which had happened, and so didn't know whether
   the memory should be freed

 - similarly, the caller had no idea if a text conversion
   had occurred, and so didn't know whether the contents
   should be treated as binary or not. This meant that we
   incorrectly guessed that text-converted content was
   binary and didn't actually show it (unless the user
   overrode us with "diff.foo.binary = false", which then
   created problems in plumbing where the text conversion
   did _not_ occur)

 - not all callers of fill_mmfile want the text contents. In
   particular, we don't really want diffstat, whitespace
   checks, patch id generation, etc, to look at the
   converted contents.

This patch pulls the conversion code directly into
builtin_diff, so that we only see the conversion when
generating an actual patch. We also then know whether we are
doing a conversion, so we can check the binary-ness and free
the data from the mmfile appropriately (the previous version
leaked quite badly when text conversion was used)

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4030-diff-textconv.sh