treewide: always have a valid "index_state.repo" member

When the "repo" member was added to "the_index" in [1] the
repo_read_index() was made to populate it, but the unpopulated
"the_index" variable didn't get the same treatment.

Let's do that in initialize_the_repository() when we set it up, and
likewise for all of the current callers initialized an empty "struct
index_state".

This simplifies code that needs to deal with "the_index" or a custom
"struct index_state", we no longer need to second-guess this part of
the "index_state" deep in the stack. A recent example of such
second-guessing is the "istate->repo ? istate->repo : the_repository"
code in [2]. We can now simply use "istate->repo".

We're doing this by making use of the INDEX_STATE_INIT() macro (and
corresponding function) added in [3], which now have mandatory "repo"
arguments.

Because we now call index_state_init() in repository.c's
initialize_the_repository() we don't need to handle the case where we
have a "repo->index" whose "repo" member doesn't match the "repo"
we're setting up, i.e. the "Complete the double-reference" code in
repo_read_index() being altered here. That logic was originally added
in [1], and was working around the lack of what we now have in
initialize_the_repository().

For "fsmonitor-settings.c" we can remove the initialization of a NULL
"r" argument to "the_repository". This was added back in [4], and was
needed at the time for callers that would pass us the "r" from an
"istate->repo". Before this change such a change to
"fsmonitor-settings.c" would segfault all over the test suite (e.g. in
t0002-gitfile.sh).

This change has wider eventual implications for
"fsmonitor-settings.c". The reason the other lazy loading behavior in
it is required (starting with "if (!r->settings.fsmonitor) ..." is
because of the previously passed "r" being "NULL".

I have other local changes on top of this which move its configuration
reading to "prepare_repo_settings()" in "repo-settings.c", as we could
now start to rely on it being called for our "r". But let's leave all
of that for now, and narrowly remove this particular part of the
lazy-loading.

1. 1fd9ae517c4 (repository: add repo reference to index_state,
   2021-01-23)
2. ee1f0c242ef (read-cache: add index.skipHash config option,
   2023-01-06)
3. 2f6b1eb794e (cache API: add a "INDEX_STATE_INIT" macro/function,
   add release_index(), 2023-01-12)
4. 1e0ea5c4316 (fsmonitor: config settings are repository-specific,
   2022-03-25)

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