| 220 | } |
| 221 | |
| 222 | func (iter *ObjectIter) toObject(obj plumbing.EncodedObject) (Object, error) { |
| 223 | switch obj.Type() { |
| 224 | case plumbing.BlobObject: |
| 225 | blob := &Blob{} |
| 226 | return blob, blob.Decode(obj) |
| 227 | case plumbing.TreeObject: |
| 228 | tree := &Tree{s: iter.s} |
| 229 | return tree, tree.Decode(obj) |
| 230 | case plumbing.CommitObject: |
| 231 | commit := &Commit{} |
| 232 | return commit, commit.Decode(obj) |
| 233 | case plumbing.TagObject: |
| 234 | tag := &Tag{} |
| 235 | return tag, tag.Decode(obj) |
| 236 | default: |
| 237 | return nil, plumbing.ErrInvalidType |
| 238 | } |
| 239 | } |