setup: don't perform lazy initialization of repository state

Under some circumstances (bogus GIT_DIR value or the discovered gitdir
is '.git') 'setup_git_directory()' won't initialize key repository
state.  This leads to inconsistent state after running the setup code.
To account for this inconsistent state, lazy initialization is done once
a caller asks for the repository's gitdir or some other piece of
repository state.  This is confusing and can be error prone.

Instead let's tighten the expected outcome of 'setup_git_directory()'
and ensure that it initializes repository state in all cases that would
have been handled by lazy initialization.

This also lets us drop the requirement to have 'have_git_dir()' check if
the environment variable GIT_DIR was set as that will be handled by the
end of the setup code.

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

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