common-main: stop munging argv[0] path

Since 650c44925 (common-main: call git_extract_argv0_path(),
2016-07-01), the argv[0] that is seen in cmd_main() of
individual programs is always the basename of the
executable, as common-main strips off the full path. This
can produce confusing results for git-daemon, which wants to
re-exec itself.

For instance, if the program was originally run as
"/usr/lib/git/git-daemon", it will try just re-execing
"git-daemon", which will find the first instance in $PATH.
If git's exec-path has not been prepended to $PATH, we may
find the git-daemon from a different version (or no
git-daemon at all).

Normally this isn't a problem. Git commands are run as "git
daemon", the git wrapper puts the exec-path at the front of
$PATH, and argv[0] is already "daemon" anyway. But running
git-daemon via its full exec-path, while not really a
recommended method, did work prior to 650c44925. Let's make
it work again.

The real goal of 650c44925 was not to munge argv[0], but to
reliably set the argv0_path global. The only reason it
munges at all is that one caller, the git.c wrapper,
piggy-backed on that computation to find the command
basename.  Instead, let's leave argv[0] untouched in
common-main, and have git.c do its own basename computation.

While we're at it, let's drop the return value from
git_extract_argv0_path(). It was only ever used in this one
callsite, and its dual purposes is what led to this
confusion in the first place.

Note that by changing the interface, the compiler can
confirm for us that there are no other callers storing the
return value. But the compiler can't tell us whether any of
the cmd_main() functions (besides git.c) were relying on the
basename munging. However, we can observe that prior to
650c44925, no other cmd_main() functions did that munging,
and no new cmd_main() functions have been introduced since
then. So we can't be regressing any of those cases.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
4 files changed
tree: e51fc16cc9374db8ac7fbb336d1c10cfada67ed4
  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. gpg-interface.c
  155. gpg-interface.h
  156. graph.c
  157. graph.h
  158. grep.c
  159. grep.h
  160. hashmap.c
  161. hashmap.h
  162. help.c
  163. help.h
  164. hex.c
  165. http-backend.c
  166. http-fetch.c
  167. http-push.c
  168. http-walker.c
  169. http.c
  170. http.h
  171. ident.c
  172. imap-send.c
  173. INSTALL
  174. khash.h
  175. kwset.c
  176. kwset.h
  177. levenshtein.c
  178. levenshtein.h
  179. LGPL-2.1
  180. line-log.c
  181. line-log.h
  182. line-range.c
  183. line-range.h
  184. list-objects.c
  185. list-objects.h
  186. ll-merge.c
  187. ll-merge.h
  188. lockfile.c
  189. lockfile.h
  190. log-tree.c
  191. log-tree.h
  192. mailinfo.c
  193. mailinfo.h
  194. mailmap.c
  195. mailmap.h
  196. Makefile
  197. match-trees.c
  198. merge-blobs.c
  199. merge-blobs.h
  200. merge-recursive.c
  201. merge-recursive.h
  202. merge.c
  203. mergesort.c
  204. mergesort.h
  205. name-hash.c
  206. notes-cache.c
  207. notes-cache.h
  208. notes-merge.c
  209. notes-merge.h
  210. notes-utils.c
  211. notes-utils.h
  212. notes.c
  213. notes.h
  214. object.c
  215. object.h
  216. pack-bitmap-write.c
  217. pack-bitmap.c
  218. pack-bitmap.h
  219. pack-check.c
  220. pack-objects.c
  221. pack-objects.h
  222. pack-revindex.c
  223. pack-revindex.h
  224. pack-write.c
  225. pack.h
  226. pager.c
  227. parse-options-cb.c
  228. parse-options.c
  229. parse-options.h
  230. patch-delta.c
  231. patch-ids.c
  232. patch-ids.h
  233. path.c
  234. pathspec.c
  235. pathspec.h
  236. pkt-line.c
  237. pkt-line.h
  238. preload-index.c
  239. pretty.c
  240. prio-queue.c
  241. prio-queue.h
  242. progress.c
  243. progress.h
  244. prompt.c
  245. prompt.h
  246. quote.c
  247. quote.h
  248. reachable.c
  249. reachable.h
  250. read-cache.c
  251. README.md
  252. ref-filter.c
  253. ref-filter.h
  254. reflog-walk.c
  255. reflog-walk.h
  256. refs.c
  257. refs.h
  258. remote-curl.c
  259. remote-testsvn.c
  260. remote.c
  261. remote.h
  262. replace_object.c
  263. rerere.c
  264. rerere.h
  265. resolve-undo.c
  266. resolve-undo.h
  267. revision.c
  268. revision.h
  269. run-command.c
  270. run-command.h
  271. send-pack.c
  272. send-pack.h
  273. sequencer.c
  274. sequencer.h
  275. server-info.c
  276. setup.c
  277. sh-i18n--envsubst.c
  278. sha1-array.c
  279. sha1-array.h
  280. sha1-lookup.c
  281. sha1-lookup.h
  282. sha1_file.c
  283. sha1_name.c
  284. shallow.c
  285. shell.c
  286. shortlog.h
  287. show-index.c
  288. sideband.c
  289. sideband.h
  290. sigchain.c
  291. sigchain.h
  292. split-index.c
  293. split-index.h
  294. strbuf.c
  295. strbuf.h
  296. streaming.c
  297. streaming.h
  298. string-list.c
  299. string-list.h
  300. submodule-config.c
  301. submodule-config.h
  302. submodule.c
  303. submodule.h
  304. symlinks.c
  305. tag.c
  306. tag.h
  307. tar.h
  308. tempfile.c
  309. tempfile.h
  310. thread-utils.c
  311. thread-utils.h
  312. trace.c
  313. trace.h
  314. trailer.c
  315. trailer.h
  316. transport-helper.c
  317. transport.c
  318. transport.h
  319. tree-diff.c
  320. tree-walk.c
  321. tree-walk.h
  322. tree.c
  323. tree.h
  324. unicode_width.h
  325. unimplemented.sh
  326. unix-socket.c
  327. unix-socket.h
  328. unpack-trees.c
  329. unpack-trees.h
  330. update_unicode.sh
  331. upload-pack.c
  332. url.c
  333. url.h
  334. urlmatch.c
  335. urlmatch.h
  336. usage.c
  337. userdiff.c
  338. userdiff.h
  339. utf8.c
  340. utf8.h
  341. varint.c
  342. varint.h
  343. version.c
  344. version.h
  345. versioncmp.c
  346. walker.c
  347. walker.h
  348. wildmatch.c
  349. wildmatch.h
  350. worktree.c
  351. worktree.h
  352. wrap-for-bin.sh
  353. wrapper.c
  354. write_or_die.c
  355. ws.c
  356. wt-status.c
  357. wt-status.h
  358. xdiff-interface.c
  359. xdiff-interface.h
  360. 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-.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