• J
    binary patch. · 051308f6
    Junio C Hamano 提交于
    This adds "binary patch" to the diff output and teaches apply
    what to do with them.
    
    On the diff generation side, traditionally, we said "Binary
    files differ\n" without giving anything other than the preimage
    and postimage object name on the index line.  This was good
    enough for applying a patch generated from your own repository
    (very useful while rebasing), because the postimage would be
    available in such a case.  However, this was not useful when the
    recipient of such a patch via e-mail were to apply it, even if
    the preimage was available.
    
    This patch allows the diff to generate "binary" patch when
    operating under --full-index option.  The binary patch follows
    the usual extended git diff headers, and looks like this:
    
    	"GIT binary patch\n"
    	<length byte><data>"\n"
    	...
    	"\n"
    
    Each line is prefixed with a "length-byte", whose value is upper
    or lowercase alphabet that encodes number of bytes that the data
    on the line decodes to (1..52 -- 'A' means 1, 'B' means 2, ...,
    'Z' means 26, 'a' means 27, ...).  <data> is 1 or more groups of
    5-byte sequence, each of which encodes up to 4 bytes in base85
    encoding.  Because 52 / 4 * 5 = 65 and we have the length byte,
    an output line is capped to 66 characters.  The payload is the
    same diff-delta as we use in the packfiles.
    
    On the consumption side, git-apply now can decode and apply the
    binary patch when --allow-binary-replacement is given, the diff
    was generated with --full-index, and the receiving repository
    has the preimage blob, which is the same condition as it always
    required when accepting an "Binary files differ\n" patch.
    Signed-off-by: NJunio C Hamano <junkio@cox.net>
    051308f6
Makefile 19.0 KB