binary patch.

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: Junio C Hamano <junkio@cox.net>
4 files changed
tree: 4449e79bcbe2ea2fb18b61f71280e29cc15823c9
  1. arm/
  2. compat/
  3. contrib/
  4. Documentation/
  5. mozilla-sha1/
  6. ppc/
  7. t/
  8. templates/
  9. xdiff/
  10. .gitignore
  11. apply.c
  12. blame.c
  13. blob.c
  14. blob.h
  15. builtin-count.c
  16. builtin-diff.c
  17. builtin-help.c
  18. builtin-log.c
  19. builtin-push.c
  20. builtin.h
  21. cache.h
  22. cat-file.c
  23. check-ref-format.c
  24. checkout-index.c
  25. clone-pack.c
  26. combine-diff.c
  27. commit-tree.c
  28. commit.c
  29. commit.h
  30. config.c
  31. connect.c
  32. convert-objects.c
  33. copy.c
  34. COPYING
  35. csum-file.c
  36. csum-file.h
  37. ctype.c
  38. daemon.c
  39. date.c
  40. delta.h
  41. describe.c
  42. diff-delta.c
  43. diff-files.c
  44. diff-index.c
  45. diff-lib.c
  46. diff-stages.c
  47. diff-tree.c
  48. diff.c
  49. diff.h
  50. diffcore-break.c
  51. diffcore-delta.c
  52. diffcore-order.c
  53. diffcore-pickaxe.c
  54. diffcore-rename.c
  55. diffcore.h
  56. entry.c
  57. environment.c
  58. exec_cmd.c
  59. exec_cmd.h
  60. fetch-clone.c
  61. fetch-pack.c
  62. fetch.c
  63. fetch.h
  64. fsck-objects.c
  65. generate-cmdlist.sh
  66. get-tar-commit-id.c
  67. git-add.sh
  68. git-am.sh
  69. git-annotate.perl
  70. git-applymbox.sh
  71. git-applypatch.sh
  72. git-archimport.perl
  73. git-bisect.sh
  74. git-branch.sh
  75. git-checkout.sh
  76. git-cherry.sh
  77. git-clean.sh
  78. git-clone.sh
  79. git-commit.sh
  80. git-compat-util.h
  81. git-cvsexportcommit.perl
  82. git-cvsimport.perl
  83. git-cvsserver.perl
  84. git-fetch.sh
  85. git-fmt-merge-msg.perl
  86. git-format-patch.sh
  87. git-grep.sh
  88. git-lost-found.sh
  89. git-ls-remote.sh
  90. git-merge-octopus.sh
  91. git-merge-one-file.sh
  92. git-merge-ours.sh
  93. git-merge-recursive.py
  94. git-merge-resolve.sh
  95. git-merge-stupid.sh
  96. git-merge.sh
  97. git-mv.perl
  98. git-parse-remote.sh
  99. git-prune.sh
  100. git-pull.sh
  101. git-push.sh
  102. git-rebase.sh
  103. git-relink.perl
  104. git-repack.sh
  105. git-request-pull.sh
  106. git-rerere.perl
  107. git-reset.sh
  108. git-resolve.sh
  109. git-revert.sh
  110. git-rm.sh
  111. git-send-email.perl
  112. git-sh-setup.sh
  113. git-shortlog.perl
  114. git-svnimport.perl
  115. git-tag.sh
  116. git-verify-tag.sh
  117. GIT-VERSION-GEN
  118. git.c
  119. git.spec.in
  120. gitk
  121. gitMergeCommon.py
  122. hash-object.c
  123. http-fetch.c
  124. http-push.c
  125. http.c
  126. http.h
  127. ident.c
  128. imap-send.c
  129. index-pack.c
  130. index.c
  131. init-db.c
  132. INSTALL
  133. local-fetch.c
  134. log-tree.c
  135. log-tree.h
  136. ls-files.c
  137. ls-tree.c
  138. mailinfo.c
  139. mailsplit.c
  140. Makefile
  141. merge-base.c
  142. merge-index.c
  143. merge-tree.c
  144. mktag.c
  145. mktree.c
  146. name-rev.c
  147. object.c
  148. object.h
  149. pack-check.c
  150. pack-objects.c
  151. pack-redundant.c
  152. pack.h
  153. pager.c
  154. patch-delta.c
  155. patch-id.c
  156. path.c
  157. peek-remote.c
  158. pkt-line.c
  159. pkt-line.h
  160. prune-packed.c
  161. quote.c
  162. quote.h
  163. read-cache.c
  164. read-tree.c
  165. README
  166. receive-pack.c
  167. refs.c
  168. refs.h
  169. repo-config.c
  170. rev-list.c
  171. rev-parse.c
  172. revision.c
  173. revision.h
  174. rsh.c
  175. rsh.h
  176. run-command.c
  177. run-command.h
  178. send-pack.c
  179. server-info.c
  180. setup.c
  181. sha1_file.c
  182. sha1_name.c
  183. shell.c
  184. show-branch.c
  185. show-index.c
  186. ssh-fetch.c
  187. ssh-pull.c
  188. ssh-push.c
  189. ssh-upload.c
  190. strbuf.c
  191. strbuf.h
  192. stripspace.c
  193. symbolic-ref.c
  194. tag.c
  195. tag.h
  196. tar-tree.c
  197. tar.h
  198. test-date.c
  199. test-delta.c
  200. tree-diff.c
  201. tree-walk.c
  202. tree-walk.h
  203. tree.c
  204. tree.h
  205. unpack-file.c
  206. unpack-objects.c
  207. update-index.c
  208. update-ref.c
  209. update-server-info.c
  210. upload-pack.c
  211. usage.c
  212. var.c
  213. verify-pack.c
  214. write-tree.c
  215. xdiff-interface.c
  216. xdiff-interface.h