t1300: `--unset-all` can leave an empty section behind (bug)

We already have a test demonstrating that removing the last entry from a config section fails to remove the section header of the now-empty section. The same can happen, of course, if we remove the last entries in one fell swoop. This is *also* a bug, and should be fixed at the same time. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Apr 9, 2018 at 10:32 UTC b73bdc34c06358359750a896983a2ea85b694ca0
1 file changed +11
t/t1300-config.sh
+11
@@ -1472,6 +1472,17 @@ test_expect_failure '--unset last key removes section (except if commented)' '
1472 test_line_count = 3 .git/config
1473 '
1474
1475 +test_expect_failure '--unset-all removes section if empty & uncommented' '
1476 + cat >.git/config <<-\EOF &&
1477 + [section]
1478 + key = value1
1479 + key = value2
1480 + EOF
1481 +
1482 + git config --unset-all section.key &&
1483 + test_line_count = 0 .git/config
1484 +'
1485 +
1486 test_expect_failure 'adding a key into an empty section reuses header' '
1487 cat >.git/config <<-\EOF &&
1488 [section]