builtin/clone: fix bundle URIs with mismatching object formats

We create the reference database in git-clone(1) quite early before
connecting to the remote repository. Given that we do not yet know about
the object format that the remote repository uses at that point in time
the consequence is that the refdb may be initialized with the wrong
object format.

This is not a problem in the context of the files backend as we do not
encode the object format anywhere, and furthermore the only reference
that we write between initializing the refdb and learning about the
object format is the "HEAD" symref. It will become a problem though once
we land the reftable backend, which indeed does require to know about
the proper object format at the time of creation. We thus need to
rearrange the logic in git-clone(1) so that we only initialize the refdb
once we have learned about the actual object format.

As a first step, move listing of remote references to happen earlier,
which also allow us to set up the hash algorithm of the repository
earlier now. While we aim to execute this logic as late as possible
until after most of the setup has happened already, detection of the
object format and thus later the setup of the reference database must
happen before any other logic that may spawn Git commands or otherwise
these Git commands may not recognize the repository as such.

The first Git step where we expect the repository to be fully initalized
is when we fetch bundles via bundle URIs. Funny enough, the comments
there also state that "the_repository must match the cloned repo", which
is indeed not necessarily the case for the hash algorithm right now. So
in practice it is the right thing to detect the remote's object format
before downloading bundle URIs anyway, and not doing so causes clones
with bundle URIs to fail when the local default object format does not
match the remote repository's format.

Unfortunately though, this creates a new issue: downloading bundles may
take a long time, so if we list refs beforehand they might've grown
stale meanwhile. It is not clear how to solve this issue except for a
second reference listing though after we have downloaded the bundles,
which may be an expensive thing to do.

Arguably though, it's preferable to have a staleness issue compared to
being unable to clone a repository altogether.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2 files changed
tree: 24c10f2aa2c8b33611d1ccb7ca812f4e8874e754
  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. oss-fuzz/
  15. perl/
  16. po/
  17. refs/
  18. reftable/
  19. sha1/
  20. sha1dc/
  21. sha256/
  22. t/
  23. templates/
  24. trace2/
  25. xdiff/
  26. .cirrus.yml
  27. .clang-format
  28. .editorconfig
  29. .gitattributes
  30. .gitignore
  31. .gitmodules
  32. .mailmap
  33. .tsan-suppressions
  34. abspath.c
  35. abspath.h
  36. aclocal.m4
  37. add-interactive.c
  38. add-interactive.h
  39. add-patch.c
  40. advice.c
  41. advice.h
  42. alias.c
  43. alias.h
  44. alloc.c
  45. alloc.h
  46. apply.c
  47. apply.h
  48. archive-tar.c
  49. archive-zip.c
  50. archive.c
  51. archive.h
  52. attr.c
  53. attr.h
  54. banned.h
  55. base85.c
  56. base85.h
  57. bisect.c
  58. bisect.h
  59. blame.c
  60. blame.h
  61. blob.c
  62. blob.h
  63. bloom.c
  64. bloom.h
  65. branch.c
  66. branch.h
  67. builtin.h
  68. bulk-checkin.c
  69. bulk-checkin.h
  70. bundle-uri.c
  71. bundle-uri.h
  72. bundle.c
  73. bundle.h
  74. cache-tree.c
  75. cache-tree.h
  76. cbtree.c
  77. cbtree.h
  78. chdir-notify.c
  79. chdir-notify.h
  80. check-builtins.sh
  81. checkout.c
  82. checkout.h
  83. chunk-format.c
  84. chunk-format.h
  85. CODE_OF_CONDUCT.md
  86. color.c
  87. color.h
  88. column.c
  89. column.h
  90. combine-diff.c
  91. command-list.txt
  92. commit-graph.c
  93. commit-graph.h
  94. commit-reach.c
  95. commit-reach.h
  96. commit-slab-decl.h
  97. commit-slab-impl.h
  98. commit-slab.h
  99. commit.c
  100. commit.h
  101. common-main.c
  102. config.c
  103. config.h
  104. config.mak.dev
  105. config.mak.in
  106. config.mak.uname
  107. configure.ac
  108. connect.c
  109. connect.h
  110. connected.c
  111. connected.h
  112. convert.c
  113. convert.h
  114. copy.c
  115. copy.h
  116. COPYING
  117. credential.c
  118. credential.h
  119. csum-file.c
  120. csum-file.h
  121. ctype.c
  122. daemon.c
  123. date.c
  124. date.h
  125. decorate.c
  126. decorate.h
  127. delta-islands.c
  128. delta-islands.h
  129. delta.h
  130. detect-compiler
  131. diagnose.c
  132. diagnose.h
  133. diff-delta.c
  134. diff-lib.c
  135. diff-merges.c
  136. diff-merges.h
  137. diff-no-index.c
  138. diff.c
  139. diff.h
  140. diffcore-break.c
  141. diffcore-delta.c
  142. diffcore-order.c
  143. diffcore-pickaxe.c
  144. diffcore-rename.c
  145. diffcore-rotate.c
  146. diffcore.h
  147. dir-iterator.c
  148. dir-iterator.h
  149. dir.c
  150. dir.h
  151. editor.c
  152. editor.h
  153. entry.c
  154. entry.h
  155. environment.c
  156. environment.h
  157. exec-cmd.c
  158. exec-cmd.h
  159. fetch-negotiator.c
  160. fetch-negotiator.h
  161. fetch-pack.c
  162. fetch-pack.h
  163. fmt-merge-msg.c
  164. fmt-merge-msg.h
  165. fsck.c
  166. fsck.h
  167. fsmonitor--daemon.h
  168. fsmonitor-ipc.c
  169. fsmonitor-ipc.h
  170. fsmonitor-ll.h
  171. fsmonitor-path-utils.h
  172. fsmonitor-settings.c
  173. fsmonitor-settings.h
  174. fsmonitor.c
  175. fsmonitor.h
  176. generate-cmdlist.sh
  177. generate-configlist.sh
  178. generate-hooklist.sh
  179. gettext.c
  180. gettext.h
  181. git-archimport.perl
  182. git-compat-util.h
  183. git-curl-compat.h
  184. git-cvsexportcommit.perl
  185. git-cvsimport.perl
  186. git-cvsserver.perl
  187. git-difftool--helper.sh
  188. git-filter-branch.sh
  189. git-instaweb.sh
  190. git-merge-octopus.sh
  191. git-merge-one-file.sh
  192. git-merge-resolve.sh
  193. git-mergetool--lib.sh
  194. git-mergetool.sh
  195. git-p4.py
  196. git-quiltimport.sh
  197. git-request-pull.sh
  198. git-send-email.perl
  199. git-sh-i18n.sh
  200. git-sh-setup.sh
  201. git-submodule.sh
  202. git-svn.perl
  203. GIT-VERSION-GEN
  204. git-web--browse.sh
  205. git-zlib.c
  206. git-zlib.h
  207. git.c
  208. git.rc
  209. gpg-interface.c
  210. gpg-interface.h
  211. graph.c
  212. graph.h
  213. grep.c
  214. grep.h
  215. hash-ll.h
  216. hash-lookup.c
  217. hash-lookup.h
  218. hash.h
  219. hashmap.c
  220. hashmap.h
  221. help.c
  222. help.h
  223. hex-ll.c
  224. hex-ll.h
  225. hex.c
  226. hex.h
  227. hook.c
  228. hook.h
  229. http-backend.c
  230. http-fetch.c
  231. http-push.c
  232. http-walker.c
  233. http.c
  234. http.h
  235. ident.c
  236. ident.h
  237. imap-send.c
  238. INSTALL
  239. iterator.h
  240. json-writer.c
  241. json-writer.h
  242. khash.h
  243. kwset.c
  244. kwset.h
  245. levenshtein.c
  246. levenshtein.h
  247. LGPL-2.1
  248. line-log.c
  249. line-log.h
  250. line-range.c
  251. line-range.h
  252. linear-assignment.c
  253. linear-assignment.h
  254. list-objects-filter-options.c
  255. list-objects-filter-options.h
  256. list-objects-filter.c
  257. list-objects-filter.h
  258. list-objects.c
  259. list-objects.h
  260. list.h
  261. lockfile.c
  262. lockfile.h
  263. log-tree.c
  264. log-tree.h
  265. ls-refs.c
  266. ls-refs.h
  267. mailinfo.c
  268. mailinfo.h
  269. mailmap.c
  270. mailmap.h
  271. Makefile
  272. match-trees.c
  273. match-trees.h
  274. mem-pool.c
  275. mem-pool.h
  276. merge-blobs.c
  277. merge-blobs.h
  278. merge-ll.c
  279. merge-ll.h
  280. merge-ort-wrappers.c
  281. merge-ort-wrappers.h
  282. merge-ort.c
  283. merge-ort.h
  284. merge-recursive.c
  285. merge-recursive.h
  286. merge.c
  287. merge.h
  288. mergesort.h
  289. midx.c
  290. midx.h
  291. name-hash.c
  292. name-hash.h
  293. notes-cache.c
  294. notes-cache.h
  295. notes-merge.c
  296. notes-merge.h
  297. notes-utils.c
  298. notes-utils.h
  299. notes.c
  300. notes.h
  301. object-file.c
  302. object-file.h
  303. object-name.c
  304. object-name.h
  305. object-store-ll.h
  306. object-store.h
  307. object.c
  308. object.h
  309. oid-array.c
  310. oid-array.h
  311. oidmap.c
  312. oidmap.h
  313. oidset.c
  314. oidset.h
  315. oidtree.c
  316. oidtree.h
  317. pack-bitmap-write.c
  318. pack-bitmap.c
  319. pack-bitmap.h
  320. pack-check.c
  321. pack-mtimes.c
  322. pack-mtimes.h
  323. pack-objects.c
  324. pack-objects.h
  325. pack-revindex.c
  326. pack-revindex.h
  327. pack-write.c
  328. pack.h
  329. packfile.c
  330. packfile.h
  331. pager.c
  332. pager.h
  333. parallel-checkout.c
  334. parallel-checkout.h
  335. parse-options-cb.c
  336. parse-options.c
  337. parse-options.h
  338. parse.c
  339. parse.h
  340. patch-delta.c
  341. patch-ids.c
  342. patch-ids.h
  343. path.c
  344. path.h
  345. pathspec.c
  346. pathspec.h
  347. pkt-line.c
  348. pkt-line.h
  349. preload-index.c
  350. preload-index.h
  351. pretty.c
  352. pretty.h
  353. prio-queue.c
  354. prio-queue.h
  355. progress.c
  356. progress.h
  357. promisor-remote.c
  358. promisor-remote.h
  359. prompt.c
  360. prompt.h
  361. protocol-caps.c
  362. protocol-caps.h
  363. protocol.c
  364. protocol.h
  365. prune-packed.c
  366. prune-packed.h
  367. quote.c
  368. quote.h
  369. range-diff.c
  370. range-diff.h
  371. reachable.c
  372. reachable.h
  373. read-cache-ll.h
  374. read-cache.c
  375. read-cache.h
  376. README.md
  377. rebase-interactive.c
  378. rebase-interactive.h
  379. rebase.c
  380. rebase.h
  381. ref-filter.c
  382. ref-filter.h
  383. reflog-walk.c
  384. reflog-walk.h
  385. reflog.c
  386. reflog.h
  387. refs.c
  388. refs.h
  389. refspec.c
  390. refspec.h
  391. remote-curl.c
  392. remote.c
  393. remote.h
  394. replace-object.c
  395. replace-object.h
  396. repo-settings.c
  397. repository.c
  398. repository.h
  399. rerere.c
  400. rerere.h
  401. reset.c
  402. reset.h
  403. resolve-undo.c
  404. resolve-undo.h
  405. revision.c
  406. revision.h
  407. run-command.c
  408. run-command.h
  409. sane-ctype.h
  410. scalar.c
  411. SECURITY.md
  412. send-pack.c
  413. send-pack.h
  414. sequencer.c
  415. sequencer.h
  416. serve.c
  417. serve.h
  418. server-info.c
  419. server-info.h
  420. setup.c
  421. setup.h
  422. sh-i18n--envsubst.c
  423. sha1dc_git.c
  424. sha1dc_git.h
  425. shallow.c
  426. shallow.h
  427. shared.mak
  428. shell.c
  429. shortlog.h
  430. sideband.c
  431. sideband.h
  432. sigchain.c
  433. sigchain.h
  434. simple-ipc.h
  435. sparse-index.c
  436. sparse-index.h
  437. split-index.c
  438. split-index.h
  439. stable-qsort.c
  440. statinfo.c
  441. statinfo.h
  442. strbuf.c
  443. strbuf.h
  444. streaming.c
  445. streaming.h
  446. string-list.c
  447. string-list.h
  448. strmap.c
  449. strmap.h
  450. strvec.c
  451. strvec.h
  452. sub-process.c
  453. sub-process.h
  454. submodule-config.c
  455. submodule-config.h
  456. submodule.c
  457. submodule.h
  458. symlinks.c
  459. symlinks.h
  460. tag.c
  461. tag.h
  462. tar.h
  463. tempfile.c
  464. tempfile.h
  465. thread-utils.c
  466. thread-utils.h
  467. tmp-objdir.c
  468. tmp-objdir.h
  469. trace.c
  470. trace.h
  471. trace2.c
  472. trace2.h
  473. trailer.c
  474. trailer.h
  475. transport-helper.c
  476. transport-internal.h
  477. transport.c
  478. transport.h
  479. tree-diff.c
  480. tree-walk.c
  481. tree-walk.h
  482. tree.c
  483. tree.h
  484. unicode-width.h
  485. unimplemented.sh
  486. unix-socket.c
  487. unix-socket.h
  488. unix-stream-server.c
  489. unix-stream-server.h
  490. unpack-trees.c
  491. unpack-trees.h
  492. upload-pack.c
  493. upload-pack.h
  494. url.c
  495. url.h
  496. urlmatch.c
  497. urlmatch.h
  498. usage.c
  499. userdiff.c
  500. userdiff.h
  501. utf8.c
  502. utf8.h
  503. varint.c
  504. varint.h
  505. version.c
  506. version.h
  507. versioncmp.c
  508. versioncmp.h
  509. walker.c
  510. walker.h
  511. wildmatch.c
  512. wildmatch.h
  513. worktree.c
  514. worktree.h
  515. wrap-for-bin.sh
  516. wrapper.c
  517. wrapper.h
  518. write-or-die.c
  519. write-or-die.h
  520. ws.c
  521. ws.h
  522. wt-status.c
  523. wt-status.h
  524. xdiff-interface.c
  525. xdiff-interface.h
README.md

Build status

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-<commandname>.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 and Documentation/CodingGuidelines).

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org (not the Git list). The mailing list archives are available at https://lore.kernel.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