| 95 | } |
| 96 | |
| 97 | func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.Hash, error) { |
| 98 | h := obj.Hash() |
| 99 | o.Objects[h] = obj |
| 100 | |
| 101 | switch obj.Type() { |
| 102 | case plumbing.CommitObject: |
| 103 | o.Commits[h] = o.Objects[h] |
| 104 | case plumbing.TreeObject: |
| 105 | o.Trees[h] = o.Objects[h] |
| 106 | case plumbing.BlobObject: |
| 107 | o.Blobs[h] = o.Objects[h] |
| 108 | case plumbing.TagObject: |
| 109 | o.Tags[h] = o.Objects[h] |
| 110 | default: |
| 111 | return h, ErrUnsupportedObjectType |
| 112 | } |
| 113 | |
| 114 | return h, nil |
| 115 | } |
| 116 | |
| 117 | func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) { |
| 118 | if _, ok := o.Objects[h]; !ok { |