built-in add -i: implement the main loop

The reason why we did not start with the main loop to begin with is that
it is the first user of `list_and_choose()`, which uses the `list()`
function that we conveniently introduced for use by the `status`
command.

In contrast to the Perl version, in the built-in interactive `add`, we
will keep the `list()` function (which only displays items) and the
`list_and_choose()` function (which uses `list()` to display the items,
and only takes care of the "and choose" part) separate.

The `list_and_choose()` function, as implemented in
`git-add--interactive.perl` knows a few more tricks than the function we
introduce in this patch:

- There is a flag to let the user select multiple items.

- In multi-select mode, the list of items is prefixed with a marker
  indicating what items have been selected.

- Initially, for each item a unique prefix is determined (if there
  exists any within the given parameters), and shown in the list, and
  accepted as a shortcut for the selection.

These features will be implemented in the C version later.

This patch does not add any new main loop command, of course, the
built-in `git add -i` still only supports the `status` command. The
remaining commands to follow over the course of the next commits.

To accommodate for listing the commands in columns, preparing for the
commands that will be implemented over the course of the next
patches/patch series, we teach the `list()` function to do precisely
that.

Note that we only have a prompt ending in a single ">" at this stage;
later commits will add commands that display a double ">>" to indicate
that the user is in a different loop than the main one.

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