Skip to content

Commit 422e8ef

Browse files
dschogitster
authored andcommitted
t1300: add a few more hairy examples of sections becoming empty
During the review of the first iteration of the patch series to remove sections that become empty upon --unset or --unset-all, Jeff King identified a couple of problematic cases with the backtracking approach that was still used then to "look backwards for the section header": https://public-inbox.org/git/[email protected]/ This patch adds a couple of concocted examples designed to fool a backtracking parser. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dde154b commit 422e8ef

File tree

1 file changed

+44
-1
lines changed

1 file changed

+44
-1
lines changed

t/t1300-config.sh

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,50 @@ test_expect_failure '--unset last key removes section (except if commented)' '
14261426
EOF
14271427
14281428
git config --unset section.key &&
1429-
test_cmp expect .git/config
1429+
test_cmp expect .git/config &&
1430+
1431+
q_to_tab >.git/config <<-\EOF &&
1432+
[one]
1433+
Qkey = "multiline \
1434+
QQ# with comment"
1435+
[two]
1436+
key = true
1437+
EOF
1438+
git config --unset two.key &&
1439+
! grep two .git/config &&
1440+
1441+
q_to_tab >.git/config <<-\EOF &&
1442+
[one]
1443+
Qkey = "multiline \
1444+
QQ# with comment"
1445+
[one]
1446+
key = true
1447+
EOF
1448+
git config --unset-all one.key &&
1449+
test_line_count = 0 .git/config &&
1450+
1451+
q_to_tab >.git/config <<-\EOF &&
1452+
[one]
1453+
Qkey = true
1454+
Q# a comment not at the start
1455+
[two]
1456+
Qkey = true
1457+
EOF
1458+
git config --unset two.key &&
1459+
grep two .git/config &&
1460+
1461+
q_to_tab >.git/config <<-\EOF &&
1462+
[one]
1463+
Qkey = not [two "subsection"]
1464+
[two "subsection"]
1465+
[two "subsection"]
1466+
Qkey = true
1467+
[TWO "subsection"]
1468+
[one]
1469+
EOF
1470+
git config --unset two.subsection.key &&
1471+
test "not [two subsection]" = "$(git config one.key)" &&
1472+
test_line_count = 3 .git/config
14301473
'
14311474

14321475
test_expect_failure 'adding a key into an empty section reuses header' '

0 commit comments

Comments
 (0)