Skip to content

Commit 66bea73

Browse files
committed
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
2 parents 68ef16b + 53ca053 commit 66bea73

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

t/t1300-repo-config.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,4 +1087,39 @@ test_expect_success 'barf on incomplete string' '
10871087
grep " line 3 " error
10881088
'
10891089

1090+
# good section hygiene
1091+
test_expect_failure 'unsetting the last key in a section removes header' '
1092+
cat >.git/config <<-\EOF &&
1093+
# some generic comment on the configuration file itself
1094+
# a comment specific to this "section" section.
1095+
[section]
1096+
# some intervening lines
1097+
# that should also be dropped
1098+
1099+
key = value
1100+
# please be careful when you update the above variable
1101+
EOF
1102+
1103+
cat >expect <<-\EOF &&
1104+
# some generic comment on the configuration file itself
1105+
EOF
1106+
1107+
git config --unset section.key &&
1108+
test_cmp expect .git/config
1109+
'
1110+
1111+
test_expect_failure 'adding a key into an empty section reuses header' '
1112+
cat >.git/config <<-\EOF &&
1113+
[section]
1114+
EOF
1115+
1116+
q_to_tab >expect <<-\EOF &&
1117+
[section]
1118+
Qkey = value
1119+
EOF
1120+
1121+
git config section.key value
1122+
test_cmp expect .git/config
1123+
'
1124+
10901125
test_done

0 commit comments

Comments
 (0)