parse-options: don't emit "ambiguous option" for aliases

Change the option parsing machinery so that e.g. "clone --recurs ..."
doesn't error out because "clone" understands both "--recursive" and
"--recurse-submodules" to mean the same thing.

Initially "clone" just understood --recursive until the
--recurses-submodules alias was added in ccdd3da652 ("clone: Add the
--recurse-submodules option as alias for --recursive",
2010-11-04). Since bb62e0a99f ("clone: teach --recurse-submodules to
optionally take a pathspec", 2017-03-17) the longer form has been
promoted to the default.

But due to the way the options parsing machinery works this resulted
in the rather absurd situation of:

    $ git clone --recurs [...]
    error: ambiguous option: recurs (could be --recursive or --recurse-submodules)

Add OPT_ALIAS() to express this link between two or more options and use
it in git-clone. Multiple aliases of an option could be written as

    OPT_ALIAS(0, "alias1", "original-name"),
    OPT_ALIAS(0, "alias2", "original-name"),
    ...

The current implementation is not exactly optimal in this case. But we
can optimize it when it becomes a problem. So far we don't even have two
aliases of any option.

A big chunk of code is actually from Junio C Hamano.

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

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