Skip to content

Commit d8e8757

Browse files
chriscoolgitster
authored andcommitted
config: add test cases for empty value and no value config variables.
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9386ecb commit d8e8757

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

t/t1300-repo-config.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,17 +297,40 @@ test_expect_success '--add' \
297297
cat > .git/config << EOF
298298
[novalue]
299299
variable
300+
[emptyvalue]
301+
variable =
300302
EOF
301303

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

307+
test_expect_success 'get variable with empty value' \
308+
'git config --get emptyvalue.variable ^$'
309+
305310
echo novalue.variable > expect
306311

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

316+
echo 'emptyvalue.variable ' > expect
317+
318+
test_expect_success 'get-regexp variable with empty value' \
319+
'git config --get-regexp emptyvalue > output &&
320+
cmp output expect'
321+
322+
echo true > expect
323+
324+
test_expect_success 'get bool variable with no value' \
325+
'git config --bool novalue.variable > output &&
326+
cmp output expect'
327+
328+
echo false > expect
329+
330+
test_expect_success 'get bool variable with empty value' \
331+
'git config --bool emptyvalue.variable > output &&
332+
cmp output expect'
333+
311334
git config > output 2>&1
312335

313336
test_expect_success 'no arguments, but no crash' \

0 commit comments

Comments
 (0)