• J
    refactor userdiff textconv code · 04427ac8
    Jeff King 提交于
    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: NJeff King <peff@peff.net>
    Signed-off-by: NJunio C Hamano <gitster@pobox.com>
    04427ac8
diff.c 87.5 KB