Fix git_config_bool_or_int

The earlier one botched the return value logic between config_bool and
config_bool_and_int.  The former should normalize between 0 and 1 while
the latter should give back full range of integer values.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2008-04-13 12:11:11 -07:00
parent f43e2fd43b
commit c35b0b5884
3 changed files with 80 additions and 4 deletions

View File

@ -595,6 +595,64 @@ test_expect_success 'set --int' '
rm .git/config
cat >expect <<\EOF
[bool]
true1 = true
true2 = true
false1 = false
false2 = false
[int]
int1 = 0
int2 = 1
int3 = -1
EOF
test_expect_success 'get --bool-or-int' '
(
echo "[bool]"
echo true1
echo true2 = true
echo false = false
echo "[int]"
echo int1 = 0
echo int2 = 1
echo int3 = -1
) >>.git/config &&
test $(git config --bool-or-int bool.true1) = true &&
test $(git config --bool-or-int bool.true2) = true &&
test $(git config --bool-or-int bool.false) = false &&
test $(git config --bool-or-int int.int1) = 0 &&
test $(git config --bool-or-int int.int2) = 1 &&
test $(git config --bool-or-int int.int3) = -1
'
rm .git/config
cat >expect <<\EOF
[bool]
true1 = true
false1 = false
true2 = true
false2 = false
[int]
int1 = 0
int2 = 1
int3 = -1
EOF
test_expect_success 'set --bool-or-int' '
git config --bool-or-int bool.true1 true &&
git config --bool-or-int bool.false1 false &&
git config --bool-or-int bool.true2 yes &&
git config --bool-or-int bool.false2 no &&
git config --bool-or-int int.int1 0 &&
git config --bool-or-int int.int2 1 &&
git config --bool-or-int int.int3 -1 &&
test_cmp expect .git/config
'
rm .git/config
git config quote.leading " test"
git config quote.ending "test "
git config quote.semicolon "test;test"