Skip to content

Commit 7785c50

Browse files
authored
Merge pull request #242 from kmala/master
deep copy slice object during append
2 parents a345f52 + 69bc7e7 commit 7785c50

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

merge/conflict.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ func ConflictsFromManagers(sets fieldpath.ManagedFields) Conflicts {
112112
set.Set().Iterate(func(p fieldpath.Path) {
113113
conflicts = append(conflicts, Conflict{
114114
Manager: manager,
115-
Path: p,
115+
Path: p.Copy(),
116116
})
117117
})
118118
}

merge/conflict_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,22 @@ func TestToSet(t *testing.T) {
9292
t.Fatalf("expected\n%v\n, but got\n%v\n", expected, actual)
9393
}
9494
}
95+
96+
func TestConflictsFromManagers(t *testing.T) {
97+
got := merge.ConflictsFromManagers(fieldpath.ManagedFields{
98+
"Bob": fieldpath.NewVersionedSet(
99+
_NS(
100+
_P("obj", "template", "obj", "list", _KBF("name", "a"), "id"),
101+
_P("obj", "template", "obj", "list", _KBF("name", "a"), "key"),
102+
),
103+
"v1",
104+
false,
105+
),
106+
})
107+
wanted := `conflicts with "Bob":
108+
- .obj.template.obj.list[name="a"].id
109+
- .obj.template.obj.list[name="a"].key`
110+
if got.Error() != wanted {
111+
t.Errorf("Got %v, wanted %v", got.Error(), wanted)
112+
}
113+
}

0 commit comments

Comments
 (0)