@@ -98,6 +98,23 @@ test_expect_success 'subsections are not canonicalized by git-config' '
98
98
test_cmp_config two section.SubSection.key
99
99
'
100
100
101
+ test_missing_key () {
102
+ local key=" $1 " &&
103
+ local title=" $2 " &&
104
+ test_expect_success " value for $title is not printed" '
105
+ test_must_fail git config "$key" >out 2>err &&
106
+ test_must_be_empty out &&
107
+ test_must_be_empty err
108
+ '
109
+ }
110
+
111
+ test_missing_key ' missingsection.missingkey' ' missing section and missing key'
112
+ test_missing_key ' missingsection.penguin' ' missing section and existing key'
113
+ test_missing_key ' section.missingkey' ' existing section and missing key'
114
+ test_missing_key ' section.MissingSubSection.missingkey' ' missing subsection and missing key'
115
+ test_missing_key ' section.SubSection.missingkey' ' existing subsection and missing key'
116
+ test_missing_key ' section.MissingSubSection.key' ' missing subsection and existing key'
117
+
101
118
cat > .git/config << \EOF
102
119
[alpha]
103
120
bar = foo
@@ -1488,35 +1505,29 @@ test_expect_success 'git config ignores pairs without count' '
1488
1505
test_must_be_empty error
1489
1506
'
1490
1507
1491
- test_expect_success ' git config ignores pairs with zero count' '
1492
- test_must_fail env \
1493
- GIT_CONFIG_COUNT=0 \
1494
- GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1495
- git config pair.one
1496
- '
1497
-
1498
1508
test_expect_success ' git config ignores pairs exceeding count' '
1499
1509
GIT_CONFIG_COUNT=1 \
1500
1510
GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1501
1511
GIT_CONFIG_KEY_1="pair.two" GIT_CONFIG_VALUE_1="value" \
1502
- git config --get-regexp "pair.*" >actual &&
1512
+ git config --get-regexp "pair.*" >actual 2>error &&
1503
1513
cat >expect <<-EOF &&
1504
1514
pair.one value
1505
1515
EOF
1506
- test_cmp expect actual
1516
+ test_cmp expect actual &&
1517
+ test_must_be_empty error
1507
1518
'
1508
1519
1509
1520
test_expect_success ' git config ignores pairs with zero count' '
1510
1521
test_must_fail env \
1511
1522
GIT_CONFIG_COUNT=0 GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1512
- git config pair.one >error &&
1523
+ git config pair.one 2 >error &&
1513
1524
test_must_be_empty error
1514
1525
'
1515
1526
1516
1527
test_expect_success ' git config ignores pairs with empty count' '
1517
1528
test_must_fail env \
1518
1529
GIT_CONFIG_COUNT= GIT_CONFIG_KEY_0="pair.one" GIT_CONFIG_VALUE_0="value" \
1519
- git config pair.one >error &&
1530
+ git config pair.one 2 >error &&
1520
1531
test_must_be_empty error
1521
1532
'
1522
1533
0 commit comments