aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/packfile/object_pack.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2018-02-13 23:43:54 +0100
committerGitHub <noreply@github.com>2018-02-13 23:43:54 +0100
commit01c428c50c89c47e40dfdd4ecf43376cf48e1797 (patch)
treea6c3209f41e5cb66d89c12a90bb68720ac2c9366 /plumbing/format/packfile/object_pack.go
parent3a9d5e236ef38854c0e0acc1ba924260060c755a (diff)
parent37c7c2b0afbf49b39fefbc525a7b2ecd60e75570 (diff)
downloadgo-git-01c428c50c89c47e40dfdd4ecf43376cf48e1797.tar.gz
Merge pull request #744 from jfontan/fix/make-sure-original-data-is-saved-before-creanup
plumbing: format/packfile, fix panic retrieving object hash.
Diffstat (limited to 'plumbing/format/packfile/object_pack.go')
-rw-r--r--plumbing/format/packfile/object_pack.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/plumbing/format/packfile/object_pack.go b/plumbing/format/packfile/object_pack.go
index 877581e..dfea571 100644
--- a/plumbing/format/packfile/object_pack.go
+++ b/plumbing/format/packfile/object_pack.go
@@ -81,15 +81,24 @@ 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
}
}
+// CleanOriginal sets Original to nil
+func (o *ObjectToPack) CleanOriginal() {
+ o.Original = nil
+}
+
func (o *ObjectToPack) Type() plumbing.ObjectType {
if o.Original != nil {
return o.Original.Type()