diff options
author | Javi Fontan <jfontan@gmail.com> | 2018-02-09 12:20:24 +0100 |
---|---|---|
committer | Javi Fontan <jfontan@gmail.com> | 2018-02-09 12:20:24 +0100 |
commit | 37c7c2b0afbf49b39fefbc525a7b2ecd60e75570 (patch) | |
tree | a6c3209f41e5cb66d89c12a90bb68720ac2c9366 /plumbing/format | |
parent | d2273d2510d16c258d46ee72b87fd28b8850f1f2 (diff) | |
download | go-git-37c7c2b0afbf49b39fefbc525a7b2ecd60e75570.tar.gz |
plumbing: format/packfile, add SaveOriginalMetadata function
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'plumbing/format')
-rw-r--r-- | plumbing/format/packfile/delta_selector.go | 2 | ||||
-rw-r--r-- | plumbing/format/packfile/object_pack.go | 12 |
2 files changed, 9 insertions, 5 deletions
diff --git a/plumbing/format/packfile/delta_selector.go b/plumbing/format/packfile/delta_selector.go index 98a91b9..6710085 100644 --- a/plumbing/format/packfile/delta_selector.go +++ b/plumbing/format/packfile/delta_selector.go @@ -231,7 +231,7 @@ func (dw *deltaSelector) walk( delete(indexMap, obj.Hash()) if obj.IsDelta() { - obj.SetOriginal(obj.Original) + obj.SaveOriginalMetadata() obj.CleanOriginal() } } diff --git a/plumbing/format/packfile/object_pack.go b/plumbing/format/packfile/object_pack.go index 661278d..dfea571 100644 --- a/plumbing/format/packfile/object_pack.go +++ b/plumbing/format/packfile/object_pack.go @@ -81,11 +81,15 @@ func (o *ObjectToPack) WantWrite() bool { // is nil Original is set but previous resolved values are kept func (o *ObjectToPack) SetOriginal(obj plumbing.EncodedObject) { o.Original = obj + o.SaveOriginalMetadata() +} - if obj != nil { - o.originalSize = obj.Size() - o.originalType = obj.Type() - o.originalHash = obj.Hash() +// SaveOriginalMetadata saves size, type and hash of Original object +func (o *ObjectToPack) SaveOriginalMetadata() { + if o.Original != nil { + o.originalSize = o.Original.Size() + o.originalType = o.Original.Type() + o.originalHash = o.Original.Hash() o.resolvedOriginal = true } } |