Skip to content

Commit

Permalink
config: add test cases for empty value and no value config variables.
Browse files Browse the repository at this point in the history
The tests in 't1300-repo-config.sh' did not check what happens when
an empty value like the following is used in the config file:

[emptyvalue]
	variable =

Also it was not checked that a variable with no value like the
following:

[novalue]
	variable

gives a boolean "true" value, while an ampty value gives a boolean
"false" value.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Christian Couder authored and Junio C Hamano committed Feb 7, 2008
1 parent e752019 commit 09bc098
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,40 @@ test_expect_success '--add' \
cat > .git/config << EOF
[novalue]
variable
[emptyvalue]
variable =
EOF

test_expect_success 'get variable with no value' \
'git config --get novalue.variable ^$'

test_expect_success 'get variable with empty value' \
'git config --get emptyvalue.variable ^$'

echo novalue.variable > expect

test_expect_success 'get-regexp variable with no value' \
'git config --get-regexp novalue > output &&
cmp output expect'

echo 'emptyvalue.variable ' > expect

test_expect_success 'get-regexp variable with empty value' \
'git config --get-regexp emptyvalue > output &&
cmp output expect'

echo true > expect

test_expect_success 'get bool variable with no value' \
'git config --bool novalue.variable > output &&
cmp output expect'

echo false > expect

test_expect_success 'get bool variable with empty value' \
'git config --bool emptyvalue.variable > output &&
cmp output expect'

git config > output 2>&1

test_expect_success 'no arguments, but no crash' \
Expand Down

0 comments on commit 09bc098

Please sign in to comment.