File tree 1 file changed +9
-1
lines changed
1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 5
5
"strings"
6
6
)
7
7
8
+ const reservedKeyPatch = "patch"
9
+
8
10
// A KeyValue object, that may hold multiple Values
9
11
type KeyValue struct {
10
12
key string
@@ -128,7 +130,13 @@ func (node *KeyValue) Parent() *KeyValue {
128
130
func (node * KeyValue ) MergeInto (parent * KeyValue ) (merged KeyValue , err error ) {
129
131
merged = * parent
130
132
if node .Key () != merged .Key () {
131
- return merged ,errors .New ("cannot merge mismatched root nodes" )
133
+ // "patch" is a special key that can appear at the root of a keyvalue
134
+ // it does what it sounds like, its ony real purpose is to patch another tree
135
+ // with its own values
136
+ if node .Key () != reservedKeyPatch || node .Parent () == nil || node .Parent ().Key () != tokenRootNodeKey {
137
+ return merged ,errors .New ("cannot merge mismatched root nodes" )
138
+ }
139
+ node .key = merged .Key ()
132
140
}
133
141
134
142
err = recursiveMerge (node , & merged )
You can’t perform that action at this time.
0 commit comments