]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/config: convert `key` to a local variable
authorPatrick Steinhardt <ps@pks.im>
Wed, 15 May 2024 06:42:58 +0000 (08:42 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 15 May 2024 14:17:56 +0000 (07:17 -0700)
commit040b141df39a952af936abf73f4e2fa5fc9954b5
tree51fe4d988c112536e78787ff7d76617e87e106c2
parentfdfaaa1b68f61eccd7423da558e9c69e3c7bb908
builtin/config: convert `key` to a local variable

The `key` variable is used by the `get_value()` function for two
purposes:

  - It is used to store the result of `git_config_parse_key()`, which is
    then passed on to `collect_config()`.

  - It is used as a store to convert the provided key to an
    all-lowercase key when `use_key_regexp` is set.

Neither of these cases warrant a global variable at all. In the former
case we can pass the key via `struct collect_config_data`. And in the
latter case we really only want to have it as a temporary local variable
such that we can free associated memory.

Refactor the code accordingly to reduce our reliance on global state.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c