MCPcopy Create free account
hub / github.com/libgit2/git2go / Peel

Method Peel

object.go:215–228  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
215func (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
230func allocObject(cobj *C.git_object, repo *Repository) *Object {
231 obj := &Object{

Callers 3

TestIndexReadTreeFunction · 0.45
appendCommitFunction · 0.45
TestObjectPeelFunction · 0.45

Calls 2

MakeGitErrorFunction · 0.85
allocObjectFunction · 0.85

Tested by 3

TestIndexReadTreeFunction · 0.36
appendCommitFunction · 0.36
TestObjectPeelFunction · 0.36