···146146 for _, oldManifestEntry := range oldManifest.GetContents() {
147147 if hash, ok := plumbing.FromHex(oldManifestEntry.GetGitHash()); ok {
148148 if manifestEntry, found := blobsNeeded[hash]; found {
149149- CopyProtoMessage(manifestEntry, oldManifestEntry)
149149+ manifestEntry.Reset()
150150+ proto.Merge(manifestEntry, oldManifestEntry)
150151 dataBytesFromOldManifest += oldManifestEntry.GetOriginalSize()
151152 delete(blobsNeeded, hash)
152153 }
-18
src/util.go
···44 "errors"
55 "io"
66 "strings"
77-88- "google.golang.org/protobuf/proto"
97)
108119type BoundedReader struct {
···8785 mediaType = strings.TrimSpace(strings.ToLower(mediaType))
8886 return
8987}
9090-9191-// Copying Protobuf messages like `*dest = *src` causes a lock to be copied, which is unsound.
9292-// Copying Protobuf messages field-wise is fragile: adding a new field to the schema does not
9393-// cause a diagnostic to be emitted pointing to the copy site, making it easy to miss updates.
9494-// Serializing and deserializing is reliable and breaks referential links.
9595-func CopyProtoMessage(dest, src proto.Message) {
9696- data, err := proto.Marshal(src)
9797- if err != nil {
9898- panic(err)
9999- }
100100-101101- err = proto.Unmarshal(data, dest)
102102- if err != nil {
103103- panic(err)
104104- }
105105-}