+2
-1
src/fetch.go
+2
-1
src/fetch.go
···
146
146
for _, oldManifestEntry := range oldManifest.GetContents() {
147
147
if hash, ok := plumbing.FromHex(oldManifestEntry.GetGitHash()); ok {
148
148
if manifestEntry, found := blobsNeeded[hash]; found {
149
-
CopyProtoMessage(manifestEntry, oldManifestEntry)
149
+
manifestEntry.Reset()
150
+
proto.Merge(manifestEntry, oldManifestEntry)
150
151
dataBytesFromOldManifest += oldManifestEntry.GetOriginalSize()
151
152
delete(blobsNeeded, hash)
152
153
}
-18
src/util.go
-18
src/util.go
···
4
4
"errors"
5
5
"io"
6
6
"strings"
7
-
8
-
"google.golang.org/protobuf/proto"
9
7
)
10
8
11
9
type BoundedReader struct {
···
87
85
mediaType = strings.TrimSpace(strings.ToLower(mediaType))
88
86
return
89
87
}
90
-
91
-
// Copying Protobuf messages like `*dest = *src` causes a lock to be copied, which is unsound.
92
-
// Copying Protobuf messages field-wise is fragile: adding a new field to the schema does not
93
-
// cause a diagnostic to be emitted pointing to the copy site, making it easy to miss updates.
94
-
// Serializing and deserializing is reliable and breaks referential links.
95
-
func CopyProtoMessage(dest, src proto.Message) {
96
-
data, err := proto.Marshal(src)
97
-
if err != nil {
98
-
panic(err)
99
-
}
100
-
101
-
err = proto.Unmarshal(data, dest)
102
-
if err != nil {
103
-
panic(err)
104
-
}
105
-
}