]> git.ipfire.org Git - thirdparty/git.git/commit
config tests: add "NULL" tests for *_get_value_multi()
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Tue, 28 Mar 2023 14:04:21 +0000 (16:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 Mar 2023 14:37:52 +0000 (07:37 -0700)
commite7587a8f53e84d4b666c0107987b0a9fa2f8336d
treea8f7b3a433b2df54d828f9895e0077c87aed0f00
parent258902ce07779a6ca532d092279c1554a199ba2a
config tests: add "NULL" tests for *_get_value_multi()

A less well known edge case in the config format is that keys can be
value-less, a shorthand syntax for "true" boolean keys. I.e. these two
are equivalent as far as "--type=bool" is concerned:

[a]key
[a]key = true

But as far as our parser is concerned the values for these two are
NULL, and "true". I.e. for a sequence like:

[a]key=x
[a]key
[a]key=y

We get a "struct string_list" with "string" members with ".string"
values of:

{ "x", NULL, "y" }

This behavior goes back to the initial implementation of
git_config_bool() in 17712991a59 (Add ".git/config" file parser,
2005-10-10).

When parts of the config_set API were tested for in [1] they didn't
add coverage for 3/4 of the "(NULL)" cases handled in
"t/helper/test-config.c". We'd test that case for "get_value", but not
"get_value_multi", "configset_get_value" and
"configset_get_value_multi".

We now cover all of those cases, which in turn expose the details of
how this part of the config API works.

1. 4c715ebb96a (test-config: add tests for the config_set API,
   2014-07-28)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t1308-config-set.sh