object-file: update the loose object map when writing loose objects

To implement SHA1 compatibility on SHA256 repositories the loose
object map needs to be updated whenver a loose object is written.
Updating the loose object map this way allows git to support
the old hash algorithm in constant time.

The functions write_loose_object, and stream_loose_object are
the only two functions that write to the loose object store.

Update stream_loose_object to compute the compatibiilty hash, update
the loose object, and then call repo_add_loose_object_map to update
the loose object map.

Update write_object_file_flags to convert the object into
it's compatibility encoding, hash the compatibility encoding,
write the object, and then update the loose object map.

Update force_object_loose to lookup the hash of the compatibility
encoding, write the loose object, and then update the loose object
map.

Update write_object_file_literally to convert the object into it's
compatibility hash encoding, hash the compatibility enconding, write
the object, and then update the loose object map, when the type string
is a known type.  For objects with an unknown type this results in a
partially broken repository, as the objects are not mapped.

The point of write_object_file_literally is to generate a partially
broken repository for testing.  For testing skipping writing the loose
object map is much more useful than refusing to write the broken
object at all.

Except that the loose objects are updated before the loose object map
I have not done any analysis to see how robust this scheme is in the
event of failure.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 file changed
tree: cb5d95f393a5622fdde99b43a0329212762f22f6
  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.c
  224. hex.h
  225. hook.c
  226. hook.h
  227. http-backend.c
  228. http-fetch.c
  229. http-push.c
  230. http-walker.c
  231. http.c
  232. http.h
  233. ident.c
  234. ident.h
  235. imap-send.c
  236. INSTALL
  237. iterator.h
  238. json-writer.c
  239. json-writer.h
  240. khash.h
  241. kwset.c
  242. kwset.h
  243. levenshtein.c
  244. levenshtein.h
  245. LGPL-2.1
  246. line-log.c
  247. line-log.h
  248. line-range.c
  249. line-range.h
  250. linear-assignment.c
  251. linear-assignment.h
  252. list-objects-filter-options.c
  253. list-objects-filter-options.h
  254. list-objects-filter.c
  255. list-objects-filter.h
  256. list-objects.c
  257. list-objects.h
  258. list.h
  259. lockfile.c
  260. lockfile.h
  261. log-tree.c
  262. log-tree.h
  263. loose.c
  264. loose.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-convert.c
  302. object-file-convert.h
  303. object-file.c
  304. object-file.h
  305. object-name.c
  306. object-name.h
  307. object-store-ll.h
  308. object-store.h
  309. object.c
  310. object.h
  311. oid-array.c
  312. oid-array.h
  313. oidmap.c
  314. oidmap.h
  315. oidset.c
  316. oidset.h
  317. oidtree.c
  318. oidtree.h
  319. pack-bitmap-write.c
  320. pack-bitmap.c
  321. pack-bitmap.h
  322. pack-check.c
  323. pack-mtimes.c
  324. pack-mtimes.h
  325. pack-objects.c
  326. pack-objects.h
  327. pack-revindex.c
  328. pack-revindex.h
  329. pack-write.c
  330. pack.h
  331. packfile.c
  332. packfile.h
  333. pager.c
  334. pager.h
  335. parallel-checkout.c
  336. parallel-checkout.h
  337. parse-options-cb.c
  338. parse-options.c
  339. parse-options.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