1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-11-02 07:17:58 +01:00

Merge branch 'jk/config-with-empty-section'

Document that "git config --unset" does not remove an empty section
head after removing the last variable in a section, and adding a
new variable does not try to reuse a leftover empty section head.

* jk/config-with-empty-section:
  t1300: document some aesthetic failures of the config editor
This commit is contained in:
Junio C Hamano 2013-04-02 15:10:53 -07:00
commit 66bea733f3

View file

@ -1087,4 +1087,39 @@ test_expect_success 'barf on incomplete string' '
grep " line 3 " error
'
# good section hygiene
test_expect_failure 'unsetting the last key in a section removes header' '
cat >.git/config <<-\EOF &&
# some generic comment on the configuration file itself
# a comment specific to this "section" section.
[section]
# some intervening lines
# that should also be dropped
key = value
# please be careful when you update the above variable
EOF
cat >expect <<-\EOF &&
# some generic comment on the configuration file itself
EOF
git config --unset section.key &&
test_cmp expect .git/config
'
test_expect_failure 'adding a key into an empty section reuses header' '
cat >.git/config <<-\EOF &&
[section]
EOF
q_to_tab >expect <<-\EOF &&
[section]
Qkey = value
EOF
git config section.key value
test_cmp expect .git/config
'
test_done