Skip to content

Commit

Permalink
Merge branch 'jk/config-with-empty-section'
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Apr 2, 2013
2 parents 68ef16b + 53ca053 commit 66bea73
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions t/t1300-repo-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 66bea73

Please sign in to comment.