t1300: `--unset-all` can leave an empty section behind (bug)
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Mon, 9 Apr 2018 08:32:02 +0000 (10:32 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Apr 2018 12:32:58 +0000 (21:32 +0900)
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>
t/t1300-config.sh
index a59c07fcb74c83d77377436f7d0864fe37ff13d7..8a3cd2c11416643af32c184bfee7bd53c6213005 100755 (executable)
@@ -1472,6 +1472,17 @@ test_expect_failure '--unset last key removes section (except if commented)' '
        test_line_count = 3 .git/config
 '
 
+test_expect_failure '--unset-all removes section if empty & uncommented' '
+       cat >.git/config <<-\EOF &&
+       [section]
+       key = value1
+       key = value2
+       EOF
+
+       git config --unset-all section.key &&
+       test_line_count = 0 .git/config
+'
+
 test_expect_failure 'adding a key into an empty section reuses header' '
        cat >.git/config <<-\EOF &&
        [section]