git/t/helper
Glen Choo a4e7e317f8 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>
2023-06-28 14:06:39 -07:00
..
.gitignore
test-advise.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-bitmap.c setup.h: move declarations for setup.c functions from cache.h 2023-03-21 10:56:54 -07:00
test-bloom.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-bundle-uri.c treewide: remove unnecessary cache.h inclusion from a few headers 2023-03-21 10:56:50 -07:00
test-cache-tree.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-chmtime.c t/helper: allow chmtime to print verbosely without modifying mtime 2023-04-14 10:27:52 -07:00
test-config.c config: add ctx arg to config_fn_t 2023-06-28 14:06:39 -07:00
test-crontab.c treewide: remove unnecessary cache.h includes in source files 2023-02-23 17:25:28 -08:00
test-csprng.c wrapper: add a helper to generate numbers from a CSPRNG 2022-01-17 14:17:48 -08:00
test-ctype.c Merge branch 'rs/test-ctype-eof' 2023-05-10 10:23:27 -07:00
test-date.c Merge branch 'en/header-split-cache-h' 2023-04-25 13:56:20 -07:00
test-delta.c treewide: remove unnecessary includes of cache.h 2023-03-21 10:56:53 -07:00
test-dir-iterator.c dir-iterator: drop unused DIR_ITERATOR_FOLLOW_SYMLINKS 2023-02-16 16:21:56 -08:00
test-drop-caches.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-dump-cache-tree.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-dump-fsmonitor.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-dump-split-index.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
test-dump-untracked-cache.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-env-helper.c env-helper: move this built-in to "test-tool env-helper" 2023-01-14 18:07:11 -08:00
test-example-decorate.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-fake-ssh.c Merge branch 'ab/various-leak-fixes' 2022-12-14 15:55:46 +09:00
test-fast-rebase.c object-name.h: move declarations for object-name.c functions from cache.h 2023-04-11 08:52:09 -07:00
test-fsmonitor-client.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-genrandom.c
test-genzeros.c test-genzeros: avoid raw write(2) 2023-02-16 08:30:38 -08:00
test-getcwd.c t0001: fix broken not-quite getcwd(3) test in bed67874e2 2021-07-30 10:18:27 -07:00
test-hash-speed.c builtins + test helpers: use return instead of exit() in cmd_* 2021-06-09 09:15:58 +09:00
test-hash.c treewide: remove unnecessary cache.h inclusion from several sources 2023-03-21 10:56:51 -07:00
test-hashmap.c t/helper/test-hashmap.c: avoid using strtok() 2023-04-24 16:01:28 -07:00
test-hexdump.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-index-version.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-json-writer.c t/helper/test-json-writer.c: avoid using strtok() 2023-04-24 16:01:28 -07:00
test-lazy-init-name-hash.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-match-trees.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-mergesort.c treewide: remove cache.h inclusion due to previous changes 2023-04-24 12:47:33 -07:00
test-mktemp.c
test-oid-array.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-oidmap.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-oidtree.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-online-cpus.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-pack-mtimes.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-parse-options.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-parse-pathspec-file.c treewide: remove unnecessary inclusion of gettext.h 2023-03-21 10:56:51 -07:00
test-partial-clone.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-path-utils.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-pcre2-config.c treewide: remove unnecessary cache.h includes in source files 2023-02-23 17:25:28 -08:00
test-pkt-line.c write-or-die.h: move declarations for write-or-die.c functions from cache.h 2023-03-21 10:56:54 -07:00
test-prio-queue.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-proc-receive.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-progress.c treewide: remove unnecessary inclusion of gettext.h 2023-03-21 10:56:51 -07:00
test-reach.c treewide: remove cache.h inclusion due to object-name.h changes 2023-04-11 08:52:09 -07:00
test-read-cache.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-read-graph.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
test-read-midx.c treewide: remove cache.h inclusion due to previous changes 2023-04-24 12:47:33 -07:00
test-ref-store.c pack-refs: teach pack-refs --include option 2023-05-12 14:54:14 -07:00
test-reftable.c reftable: ensure git-compat-util.h is the first (indirect) include 2023-04-24 12:47:33 -07:00
test-regex.c test-tool regex: call regfree(), fix memory leaks 2022-07-01 13:38:50 -07:00
test-repository.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-revision-walking.c Merge branch 'en/header-split-cleanup' 2023-04-06 13:38:31 -07:00
test-rot13-filter.c t0021: implementation the rot13-filter.pl script in C 2022-08-14 22:57:12 -07:00
test-run-command.c treewide: remove unnecessary inclusion of gettext.h 2023-03-21 10:56:51 -07:00
test-scrap-cache-tree.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-serve-v2.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-sha1.c Makefile & test-tool: replace "DC_SHA1" variable with a "define" 2022-11-07 22:11:51 -05:00
test-sha1.sh
test-sha256.c
test-sigchain.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-simple-ipc.c treewide: remove unnecessary cache.h includes in source files 2023-02-23 17:25:28 -08:00
test-strcmp-offset.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00
test-string-list.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-submodule-config.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-submodule-nested-repo-config.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-submodule.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-subprocess.c treewide: remove cache.h inclusion due to setup.h changes 2023-03-21 10:56:54 -07:00
test-tool-utils.h submodule--helper: move "is-active" to a test-tool 2022-09-02 09:16:23 -07:00
test-tool.c env-helper: move this built-in to "test-tool env-helper" 2023-01-14 18:07:11 -08:00
test-tool.h env-helper: move this built-in to "test-tool env-helper" 2023-01-14 18:07:11 -08:00
test-trace2.c Merge branch 'en/header-split-cache-h-part-2' 2023-05-09 16:45:46 -07:00
test-urlmatch-normalization.c test-tool urlmatch-normalization: fix a memory leak 2022-07-01 13:38:49 -07:00
test-userdiff.c config: add ctx arg to config_fn_t 2023-06-28 14:06:39 -07:00
test-wildmatch.c treewide: remove unnecessary cache.h includes in source files 2023-02-23 17:25:28 -08:00
test-windows-named-pipe.c
test-write-cache.c hash-ll.h: split out of hash.h to remove dependency on repository.h 2023-04-24 12:47:32 -07:00
test-xml-encode.c t/helper: mark unused argv/argc arguments 2023-03-28 14:11:24 -07:00