introduce delta objects with offset to base

This adds a new object, namely OBJ_OFS_DELTA, renames OBJ_DELTA to
OBJ_REF_DELTA to better make the distinction between those two delta
objects, and adds support for the handling of those new delta objects
in sha1_file.c only.

The OBJ_OFS_DELTA contains a relative offset from the delta object's
position in a pack instead of the 20-byte SHA1 reference to identify
the base object.  Since the base is likely to be not so far away, the
relative offset is more likely to have a smaller encoding on average
than an absolute offset.  And for those delta objects the base must
always be stored first because there is no way to know the distance of
later objects when streaming a pack.  Hence this relative offset is
always meant to be negative.

The offset encoding is slightly denser than the one used for object
size -- credits to <linux@horizon.com> (whoever this is) for bringing
it to my attention.

This allows for pack size reduction between 3.2% (Linux-2.6) to over 5%
(linux-historic).  Runtime pack access should be faster too since delta
replay does skip a search in the pack index for each delta in a chain.

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