aboutsummaryrefslogtreecommitdiffhomepage
path: root/config/defaultConfigProvider.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2021-06-27 13:24:49 +0200
committerBjørn Erik Pedersen <[email protected]>2021-06-27 15:01:56 +0200
commit19aa95fc7f4cd58dcc8a8ff075762cfc86d41dc3 (patch)
tree59b96d8099fb7a18e7e55ba9a115163c9dea6043 /config/defaultConfigProvider.go
parent923dd9d1c1f649142f3f377109318b07e0f44d5d (diff)
downloadhugo-19aa95fc7f4cd58dcc8a8ff075762cfc86d41dc3.tar.gz
hugo-19aa95fc7f4cd58dcc8a8ff075762cfc86d41dc3.zip
Fix config handling with empty config entries after merge
Fixes #8701
Diffstat (limited to 'config/defaultConfigProvider.go')
-rw-r--r--config/defaultConfigProvider.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/config/defaultConfigProvider.go b/config/defaultConfigProvider.go
index a5e2d09fd..80353664e 100644
--- a/config/defaultConfigProvider.go
+++ b/config/defaultConfigProvider.go
@@ -214,6 +214,7 @@ func (c *defaultConfigProvider) Merge(k string, v interface{}) {
if p, ok := maps.ToParamsAndPrepare(v); ok {
// As there may be keys in p not in root, we need to handle
// those as a special case.
+ var keysToDelete []string
for kk, vv := range p {
if pp, ok := vv.(maps.Params); ok {
if pppi, ok := c.root[kk]; ok {
@@ -261,14 +262,19 @@ func (c *defaultConfigProvider) Merge(k string, v interface{}) {
strategy := c.determineMergeStrategy(KeyParams{Key: "", Params: c.root}, KeyParams{Key: kk, Params: np})
np.SetDefaultMergeStrategy(strategy)
np.Merge(pp)
- if len(np) > 0 {
- c.root[kk] = np
+ c.root[kk] = np
+ if np.IsZero() {
+ // Just keep it until merge is done.
+ keysToDelete = append(keysToDelete, kk)
}
}
}
}
// Merge the rest.
c.root.Merge(p)
+ for _, k := range keysToDelete {
+ delete(c.root, k)
+ }
} else {
panic(fmt.Sprintf("unsupported type %T received in Merge", v))
}