Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> writes: > Now that we're using git_config_tristate() internally let's expose it > via "git config" like we do "bool", "int" etc for completeness, and so > that we can easily test it. > > Unlike the --type=bool-or-str option added in dbd8c09bfe (mergetool: > allow auto-merge for meld to follow the vim-diff behavior, 2020-05-07) > we don't have or anticipate any in-tree user of this except the tests. > > Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx> OK. > @@ -263,6 +267,12 @@ static int format_config(struct strbuf *buf, const char *key_, const char *value > strbuf_addstr(buf, value_); > else > strbuf_addstr(buf, v ? "true" : "false"); > + } else if (type == TYPE_BOOL_OR_AUTO) { > + int v = git_config_tristate(key_, value_); > + if (v == 2) > + strbuf_addstr(buf, "auto"); > + else > + strbuf_addstr(buf, v ? "true" : "false"); Makes sense. > +test_expect_success 'there is no --bool-or-auto, --<type> is deprecated in favor of --type=<type>' ' > + test_expect_code 129 git config --bool-or-auto > +' > + > +test_expect_success 'get --type=bool-or-auto' ' > + cat >.git/config <<-\EOF && > + [bool] > + true1 > + true2 = true > + false = false > + [int] > + int1 = 0 > + int2 = 1 > + int3 = -1 > + [string] > + string1 = hello > + string2 = there you > + [auto] > + auto1 = auto > + auto2 = AUTO > + [bad-auto] > + bad-auto1 = AUTOMATIC > + EOF > + cat >expect <<-\EOF && > + true > + true > + false > + false > + true > + true > + auto > + auto > + EOF Almost the same comment applies to the expected output as the earlier patch. Other than that, (and adjusting for 2 that should be turned into symbolic constant in an earlier step in a reroll), this step looks quite sensible. Thanks. > + { > + git config --type=bool-or-auto bool.true1 && > + git config --type=bool-or-auto bool.true2 && > + git config --type=bool-or-auto bool.false && > + git config --type=bool-or-auto int.int1 && > + git config --type=bool-or-auto int.int2 && > + git config --type=bool-or-auto int.int3 && > + git config --type=bool-or-auto auto.auto1 && > + git config --type=bool-or-auto auto.auto2 > + } >actual && > + test_cmp expect actual && > + > + test_must_fail git config --type=bool-or-auto --get bad-auto.bad-auto1 2>err && > + grep "bad tristate config value" err > +' > + > cat >expect <<\EOF > [bool] > true1 = true