summaryrefslogtreecommitdiff
path: root/t/t1300-config.sh
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-04-09 08:31:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-09 12:32:58 (GMT)
commit422e8ef26d35a7e54d5b7b990669f4a525cb8828 (patch)
treec075dfc253f9546269fe76d22f9446f5bb68136b /t/t1300-config.sh
parentdde154b5bd84e6258b496498901eb24b4914ec6b (diff)
downloadgit-422e8ef26d35a7e54d5b7b990669f4a525cb8828.zip
git-422e8ef26d35a7e54d5b7b990669f4a525cb8828.tar.gz
git-422e8ef26d35a7e54d5b7b990669f4a525cb8828.tar.bz2
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/20180329213229.GG2939@sigill.intra.peff.net/ This patch adds a couple of concocted examples designed to fool a backtracking parser. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t1300-config.sh')
-rwxr-xr-xt/t1300-config.sh45
1 files changed, 44 insertions, 1 deletions
diff --git a/t/t1300-config.sh b/t/t1300-config.sh
index 3ab83ff..a59c07f 100755
--- a/t/t1300-config.sh
+++ b/t/t1300-config.sh
@@ -1426,7 +1426,50 @@ test_expect_failure '--unset last key removes section (except if commented)' '
EOF
git config --unset section.key &&
- test_cmp expect .git/config
+ test_cmp expect .git/config &&
+
+ q_to_tab >.git/config <<-\EOF &&
+ [one]
+ Qkey = "multiline \
+ QQ# with comment"
+ [two]
+ key = true
+ EOF
+ git config --unset two.key &&
+ ! grep two .git/config &&
+
+ q_to_tab >.git/config <<-\EOF &&
+ [one]
+ Qkey = "multiline \
+ QQ# with comment"
+ [one]
+ key = true
+ EOF
+ git config --unset-all one.key &&
+ test_line_count = 0 .git/config &&
+
+ q_to_tab >.git/config <<-\EOF &&
+ [one]
+ Qkey = true
+ Q# a comment not at the start
+ [two]
+ Qkey = true
+ EOF
+ git config --unset two.key &&
+ grep two .git/config &&
+
+ q_to_tab >.git/config <<-\EOF &&
+ [one]
+ Qkey = not [two "subsection"]
+ [two "subsection"]
+ [two "subsection"]
+ Qkey = true
+ [TWO "subsection"]
+ [one]
+ EOF
+ git config --unset two.subsection.key &&
+ test "not [two subsection]" = "$(git config one.key)" &&
+ test_line_count = 3 .git/config
'
test_expect_failure 'adding a key into an empty section reuses header' '