pack-objects: fix off-by-one in delta-island tree-depth computation

When delta-islands are in use, we need to record the deepest path at
which we find each tree and blob. Our loop to do so counts slashes, so
"foo" is depth 0, "foo/bar" is depth 1, and so on.

However, this neglects root trees, which are represented by the empty
string. Those also have depth 0, but are at a layer above "foo". Thus,
"foo" should be 1, "foo/bar" at 2, and so on. We use this depth to
topo-sort the trees in resolve_tree_islands(). As a result, we may fail
to visit a root tree before the sub-trees it contains, and therefore not
correctly pass down the island marks.

That in turn could lead to missing some delta opportunities (objects are
in the same island, but we didn't realize it) or creating unwanted
cross-island deltas (one object is in an island another isn't, but we
don't realize). In practice, it seems to have only a small effect.  Some
experiments on the real-world git/git fork network at GitHub showed an
improvement of only 0.14% in the resulting clone size.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: 274ffd2cd3a6c2514e89d9f7f1020bcc4a377633
  1. .github/
  2. block-sha1/
  3. builtin/
  4. ci/
  5. compat/
  6. contrib/
  7. Documentation/
  8. ewah/
  9. git-gui/
  10. gitk-git/
  11. gitweb/
  12. mergetools/
  13. negotiator/
  14. perl/
  15. po/
  16. ppc/
  17. refs/
  18. sha1dc/
  19. t/
  20. templates/
  21. vcs-svn/
  22. xdiff/
  23. .clang-format
  24. .gitattributes
  25. .gitignore
  26. .gitmodules
  27. .mailmap
  28. .travis.yml
  29. .tsan-suppressions
  30. abspath.c
  31. aclocal.m4
  32. advice.c
  33. advice.h
  34. alias.c
  35. alias.h
  36. alloc.c
  37. alloc.h
  38. apply.c
  39. apply.h
  40. archive-tar.c
  41. archive-zip.c
  42. archive.c
  43. archive.h
  44. argv-array.c
  45. argv-array.h
  46. attr.c
  47. attr.h
  48. base85.c
  49. bisect.c
  50. bisect.h
  51. blame.c
  52. blame.h
  53. blob.c
  54. blob.h
  55. branch.c
  56. branch.h
  57. builtin.h
  58. bulk-checkin.c
  59. bulk-checkin.h
  60. bundle.c
  61. bundle.h
  62. cache-tree.c
  63. cache-tree.h
  64. cache.h
  65. chdir-notify.c
  66. chdir-notify.h
  67. check-builtins.sh
  68. check-racy.c
  69. check_bindir
  70. checkout.c
  71. checkout.h
  72. color.c
  73. color.h
  74. column.c
  75. column.h
  76. combine-diff.c
  77. command-list.txt
  78. commit-graph.c
  79. commit-graph.h
  80. commit-slab-decl.h
  81. commit-slab-impl.h
  82. commit-slab.h
  83. commit.c
  84. commit.h
  85. common-main.c
  86. config.c
  87. config.h
  88. config.mak.dev
  89. config.mak.in
  90. config.mak.uname
  91. configure.ac
  92. connect.c
  93. connect.h
  94. connected.c
  95. connected.h
  96. convert.c
  97. convert.h
  98. copy.c
  99. COPYING
  100. credential-cache--daemon.c
  101. credential-cache.c
  102. credential-store.c
  103. credential.c
  104. credential.h
  105. csum-file.c
  106. csum-file.h
  107. ctype.c
  108. daemon.c
  109. date.c
  110. decorate.c
  111. decorate.h
  112. delta-islands.c
  113. delta-islands.h
  114. delta.h
  115. detect-compiler
  116. diff-delta.c
  117. diff-lib.c
  118. diff-no-index.c
  119. diff.c
  120. diff.h
  121. diffcore-break.c
  122. diffcore-delta.c
  123. diffcore-order.c
  124. diffcore-pickaxe.c
  125. diffcore-rename.c
  126. diffcore.h
  127. dir-iterator.c
  128. dir-iterator.h
  129. dir.c
  130. dir.h
  131. editor.c
  132. entry.c
  133. environment.c
  134. exec-cmd.c
  135. exec-cmd.h
  136. fast-import.c
  137. fetch-negotiator.c
  138. fetch-negotiator.h
  139. fetch-object.c
  140. fetch-object.h
  141. fetch-pack.c
  142. fetch-pack.h
  143. fmt-merge-msg.h
  144. fsck.c
  145. fsck.h
  146. fsmonitor.c
  147. fsmonitor.h
  148. generate-cmdlist.sh
  149. gettext.c
  150. gettext.h
  151. git-add--interactive.perl
  152. git-archimport.perl
  153. git-bisect.sh
  154. git-compat-util.h
  155. git-cvsexportcommit.perl
  156. git-cvsimport.perl
  157. git-cvsserver.perl
  158. git-difftool--helper.sh
  159. git-filter-branch.sh
  160. git-instaweb.sh
  161. git-merge-octopus.sh
  162. git-merge-one-file.sh
  163. git-merge-resolve.sh
  164. git-mergetool--lib.sh
  165. git-mergetool.sh
  166. git-p4.py
  167. git-parse-remote.sh
  168. git-quiltimport.sh
  169. git-rebase--am.sh
  170. git-rebase--interactive.sh
  171. git-rebase--merge.sh
  172. git-rebase--preserve-merges.sh
  173. git-rebase.sh
  174. git-remote-testgit.sh
  175. git-request-pull.sh
  176. git-send-email.perl
  177. git-sh-i18n.sh
  178. git-sh-setup.sh
  179. git-stash.sh
  180. git-submodule.sh
  181. git-svn.perl
  182. GIT-VERSION-GEN
  183. git-web--browse.sh
  184. git.c
  185. git.rc
  186. gpg-interface.c
  187. gpg-interface.h
  188. graph.c
  189. graph.h
  190. grep.c
  191. grep.h
  192. hash.h
  193. hashmap.c
  194. hashmap.h
  195. help.c
  196. help.h
  197. hex.c
  198. http-backend.c
  199. http-fetch.c
  200. http-push.c
  201. http-walker.c
  202. http.c
  203. http.h
  204. ident.c
  205. imap-send.c
  206. INSTALL
  207. iterator.h
  208. khash.h
  209. kwset.c
  210. kwset.h
  211. levenshtein.c
  212. levenshtein.h
  213. LGPL-2.1
  214. line-log.c
  215. line-log.h
  216. line-range.c
  217. line-range.h
  218. list-objects-filter-options.c
  219. list-objects-filter-options.h
  220. list-objects-filter.c
  221. list-objects-filter.h
  222. list-objects.c
  223. list-objects.h
  224. list.h
  225. ll-merge.c
  226. ll-merge.h
  227. lockfile.c
  228. lockfile.h
  229. log-tree.c
  230. log-tree.h
  231. ls-refs.c
  232. ls-refs.h
  233. mailinfo.c
  234. mailinfo.h
  235. mailmap.c
  236. mailmap.h
  237. Makefile
  238. match-trees.c
  239. mem-pool.c
  240. mem-pool.h
  241. merge-blobs.c
  242. merge-blobs.h
  243. merge-recursive.c
  244. merge-recursive.h
  245. merge.c
  246. mergesort.c
  247. mergesort.h
  248. name-hash.c
  249. notes-cache.c
  250. notes-cache.h
  251. notes-merge.c
  252. notes-merge.h
  253. notes-utils.c
  254. notes-utils.h
  255. notes.c
  256. notes.h
  257. object-store.h
  258. object.c
  259. object.h
  260. oidmap.c
  261. oidmap.h
  262. oidset.c
  263. oidset.h
  264. pack-bitmap-write.c
  265. pack-bitmap.c
  266. pack-bitmap.h
  267. pack-check.c
  268. pack-objects.c
  269. pack-objects.h
  270. pack-revindex.c
  271. pack-revindex.h
  272. pack-write.c
  273. pack.h
  274. packfile.c
  275. packfile.h
  276. pager.c
  277. parse-options-cb.c
  278. parse-options.c
  279. parse-options.h
  280. patch-delta.c
  281. patch-ids.c
  282. patch-ids.h
  283. path.c
  284. path.h
  285. pathspec.c
  286. pathspec.h
  287. pkt-line.c
  288. pkt-line.h
  289. preload-index.c
  290. pretty.c
  291. pretty.h
  292. prio-queue.c
  293. prio-queue.h
  294. progress.c
  295. progress.h
  296. prompt.c
  297. prompt.h
  298. protocol.c
  299. protocol.h
  300. quote.c
  301. quote.h
  302. reachable.c
  303. reachable.h
  304. read-cache.c
  305. README.md
  306. ref-filter.c
  307. ref-filter.h
  308. reflog-walk.c
  309. reflog-walk.h
  310. refs.c
  311. refs.h
  312. refspec.c
  313. refspec.h
  314. remote-curl.c
  315. remote-testsvn.c
  316. remote.c
  317. remote.h
  318. replace-object.c
  319. replace-object.h
  320. repository.c
  321. repository.h
  322. rerere.c
  323. rerere.h
  324. resolve-undo.c
  325. resolve-undo.h
  326. revision.c
  327. revision.h
  328. run-command.c
  329. run-command.h
  330. send-pack.c
  331. send-pack.h
  332. sequencer.c
  333. sequencer.h
  334. serve.c
  335. serve.h
  336. server-info.c
  337. setup.c
  338. sh-i18n--envsubst.c
  339. sha1-array.c
  340. sha1-array.h
  341. sha1-file.c
  342. sha1-lookup.c
  343. sha1-lookup.h
  344. sha1-name.c
  345. sha1dc_git.c
  346. sha1dc_git.h
  347. shallow.c
  348. shell.c
  349. shortlog.h
  350. sideband.c
  351. sideband.h
  352. sigchain.c
  353. sigchain.h
  354. split-index.c
  355. split-index.h
  356. strbuf.c
  357. strbuf.h
  358. streaming.c
  359. streaming.h
  360. string-list.c
  361. string-list.h
  362. sub-process.c
  363. sub-process.h
  364. submodule-config.c
  365. submodule-config.h
  366. submodule.c
  367. submodule.h
  368. symlinks.c
  369. tag.c
  370. tag.h
  371. tar.h
  372. tempfile.c
  373. tempfile.h
  374. thread-utils.c
  375. thread-utils.h
  376. tmp-objdir.c
  377. tmp-objdir.h
  378. trace.c
  379. trace.h
  380. trailer.c
  381. trailer.h
  382. transport-helper.c
  383. transport-internal.h
  384. transport.c
  385. transport.h
  386. tree-diff.c
  387. tree-walk.c
  388. tree-walk.h
  389. tree.c
  390. tree.h
  391. unicode-width.h
  392. unimplemented.sh
  393. unix-socket.c
  394. unix-socket.h
  395. unpack-trees.c
  396. unpack-trees.h
  397. upload-pack.c
  398. upload-pack.h
  399. url.c
  400. url.h
  401. urlmatch.c
  402. urlmatch.h
  403. usage.c
  404. userdiff.c
  405. userdiff.h
  406. utf8.c
  407. utf8.h
  408. varint.c
  409. varint.h
  410. version.c
  411. version.h
  412. versioncmp.c
  413. walker.c
  414. walker.h
  415. wildmatch.c
  416. wildmatch.h
  417. worktree.c
  418. worktree.h
  419. wrap-for-bin.sh
  420. wrapper.c
  421. write-or-die.c
  422. ws.c
  423. wt-status.c
  424. wt-status.h
  425. xdiff-interface.c
  426. xdiff-interface.h
  427. zlib.c
README.md

Git - fast, scalable, distributed revision control system

Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals.

Git is an Open Source project covered by the GNU General Public License version 2 (some parts of it are under different licenses, compatible with the GPLv2). It was originally written by Linus Torvalds with help of a group of hackers around the net.

Please read the file INSTALL for installation instructions.

Many Git online resources are accessible from https://git-scm.com/ including full documentation and Git related tools.

See Documentation/gittutorial.txt to get started, then see Documentation/giteveryday.txt for a useful minimum set of commands, and Documentation/git-.txt for documentation of each command. If git has been correctly installed, then the tutorial can also be read with man gittutorial or git help tutorial, and the documentation of each command with man git-<commandname> or git help <commandname>.

CVS users may also want to read Documentation/gitcvs-migration.txt (man gitcvs-migration or git help cvs-migration if git is installed).

The user discussion and development of Git take place on the Git mailing list -- everyone is welcome to post bug reports, feature requests, comments and patches to git@vger.kernel.org (read Documentation/SubmittingPatches for instructions on patch submission). To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org. The mailing list archives are available at https://public-inbox.org/git/, http://marc.info/?l=git and other archival sites.

Issues which are security relevant should be disclosed privately to the Git Security mailing list git-security@googlegroups.com.

The maintainer frequently sends the “What's cooking” reports that list the current status of various development topics to the mailing list. The discussion following them give a good reference for project status, development direction and remaining tasks.

The name “git” was given by Linus Torvalds when he wrote the very first version. He described the tool as “the stupid content tracker” and the name as (depending on your mood):

  • random three-letter combination that is pronounceable, and not actually used by any common UNIX command. The fact that it is a mispronunciation of “get” may or may not be relevant.
  • stupid. contemptible and despicable. simple. Take your pick from the dictionary of slang.
  • “global information tracker”: you're in a good mood, and it actually works for you. Angels sing, and a light suddenly fills the room.
  • “goddamn idiotic truckload of sh*t”: when it breaks