common-main: call git_extract_argv0_path()

Every program which links against libgit.a must call this
function, or risk hitting an assert() in system_path() that
checks whether we have configured argv0_path (though only
when RUNTIME_PREFIX is defined, so essentially only on
Windows).

Looking at the diff, you can see that putting it into the
common main() saves us having to do it individually in each
of the external commands. But what you can't see are the
cases where we _should_ have been doing so, but weren't
(e.g., git-credential-store, and all of the t/helper test
programs).

This has been an accident-waiting-to-happen for a long time,
but wasn't triggered until recently because it involves one
of those programs actually calling system_path(). That
happened with git-credential-store in v2.8.0 with ae5f677
(lazily load core.sharedrepository, 2016-03-11). The
program:

  - takes a lock file, which...

  - opens a tempfile, which...

  - calls adjust_shared_perm to fix permissions, which...

  - lazy-loads the config (as of ae5f677), which...

  - calls system_path() to find the location of
    /etc/gitconfig

On systems with RUNTIME_PREFIX, this means credential-store
reliably hits that assert() and cannot be used.

We never noticed in the test suite, because we set
GIT_CONFIG_NOSYSTEM there, which skips the system_path()
lookup entirely.  But if we were to tweak git_config() to
find /etc/gitconfig even when we aren't going to open it,
then the test suite shows multiple failures (for
credential-store, and for some other test helpers). I didn't
include that tweak here because it's way too specific to
this particular call to be worth carrying around what is
essentially dead code.

The implementation is fairly straightforward, with one
exception: there is exactly one caller (git.c) that actually
cares about the result of the function, and not the
side-effect of setting up argv0_path. We can accommodate
that by simply replacing the value of argv[0] in the array
we hand down to cmd_main().

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