Peel recursively peels an object until an object of the specified type is met. If the query cannot be satisfied due to the object model, ErrorCodeInvalidSpec will be returned (e.g. trying to peel a blob to a tree). If you pass ObjectAny as the target type, then the object will be peeled until the
(t ObjectType)
| 213 | // If peeling a tag we discover an object which cannot be peeled to the target |
| 214 | // type due to the object model, an error will be returned. |
| 215 | func (o *Object) Peel(t ObjectType) (*Object, error) { |
| 216 | var cobj *C.git_object |
| 217 | |
| 218 | runtime.LockOSThread() |
| 219 | defer runtime.UnlockOSThread() |
| 220 | |
| 221 | err := C.git_object_peel(&cobj, o.ptr, C.git_object_t(t)) |
| 222 | runtime.KeepAlive(o) |
| 223 | if err < 0 { |
| 224 | return nil, MakeGitError(err) |
| 225 | } |
| 226 | |
| 227 | return allocObject(cobj, o.repo), nil |
| 228 | } |
| 229 | |
| 230 | func allocObject(cobj *C.git_object, repo *Repository) *Object { |
| 231 | obj := &Object{ |