config: add ctx arg to config_fn_t

Add a new "const struct config_context *ctx" arg to config_fn_t to hold
additional information about the config iteration operation.
config_context has a "struct key_value_info kvi" member that holds
metadata about the config source being read (e.g. what kind of config
source it is, the filename, etc). In this series, we're only interested
in .kvi, so we could have just used "struct key_value_info" as an arg,
but config_context makes it possible to add/adjust members in the future
without changing the config_fn_t signature. We could also consider other
ways of organizing the args (e.g. moving the config name and value into
config_context or key_value_info), but in my experiments, the
incremental benefit doesn't justify the added complexity (e.g. a
config_fn_t will sometimes invoke another config_fn_t but with a
different config value).

In subsequent commits, the .kvi member will replace the global "struct
config_reader" in config.c, making config iteration a global-free
operation. It requires much more work for the machinery to provide
meaningful values of .kvi, so for now, merely change the signature and
call sites, pass NULL as a placeholder value, and don't rely on the arg
in any meaningful way.

Most of the changes are performed by
contrib/coccinelle/config_fn_ctx.pending.cocci, which, for every
config_fn_t:

- Modifies the signature to accept "const struct config_context *ctx"
- Passes "ctx" to any inner config_fn_t, if needed
- Adds UNUSED attributes to "ctx", if needed

Most config_fn_t instances are easily identified by seeing if they are
called by the various config functions. Most of the remaining ones are
manually named in the .cocci patch. Manual cleanups are still needed,
but the majority of it is trivial; it's either adjusting config_fn_t
that the .cocci patch didn't catch, or adding forward declarations of
"struct config_context ctx" to make the signatures make sense.

The non-trivial changes are in cases where we are invoking a config_fn_t
outside of config machinery, and we now need to decide what value of
"ctx" to pass. These cases are:

- trace2/tr2_cfg.c:tr2_cfg_set_fl()

  This is indirectly called by git_config_set() so that the trace2
  machinery can notice the new config values and update its settings
  using the tr2 config parsing function, i.e. tr2_cfg_cb().

- builtin/checkout.c:checkout_main()

  This calls git_xmerge_config() as a shorthand for parsing a CLI arg.
  This might be worth refactoring away in the future, since
  git_xmerge_config() can call git_default_config(), which can do much
  more than just parsing.

Handle them by creating a KVI_INIT macro that initializes "struct
key_value_info" to a reasonable default, and use that to construct the
"ctx" arg.

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

Those wishing to help with error message, usage and informational message string translations (localization l10) should see po/README.md (a po file is a Portable Object file that holds the translations).

To subscribe to the list, send an email with just “subscribe git” in the body to majordomo@vger.kernel.org (not the Git list). The mailing list archives are available at https://lore.kernel.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