Example #1
0
func allocObject(cobj *C.git_object) Object {

	switch ObjectType(C.git_object_type(cobj)) {
	case ObjectCommit:
		commit := &Commit{
			gitObject: gitObject{cobj},
			cast_ptr:  (*C.git_commit)(cobj),
		}
		runtime.SetFinalizer(commit, (*Commit).Free)
		return commit

	case ObjectTree:
		tree := &Tree{
			gitObject: gitObject{cobj},
			cast_ptr:  (*C.git_tree)(cobj),
		}
		runtime.SetFinalizer(tree, (*Tree).Free)
		return tree

	case ObjectBlob:
		blob := &Blob{
			gitObject: gitObject{cobj},
			cast_ptr:  (*C.git_blob)(cobj),
		}
		runtime.SetFinalizer(blob, (*Blob).Free)
		return blob
	}

	return nil
}
Example #2
0
File: object.go Project: wid/git2go
func allocObject(cobj *C.git_object, repo *Repository) Object {
	obj := gitObject{
		ptr:  cobj,
		repo: repo,
	}

	switch ObjectType(C.git_object_type(cobj)) {
	case ObjectCommit:
		commit := &Commit{
			gitObject: obj,
			cast_ptr:  (*C.git_commit)(cobj),
		}
		runtime.SetFinalizer(commit, (*Commit).Free)
		return commit

	case ObjectTree:
		tree := &Tree{
			gitObject: obj,
			cast_ptr:  (*C.git_tree)(cobj),
		}
		runtime.SetFinalizer(tree, (*Tree).Free)
		return tree

	case ObjectBlob:
		blob := &Blob{
			gitObject: obj,
			cast_ptr:  (*C.git_blob)(cobj),
		}
		runtime.SetFinalizer(blob, (*Blob).Free)
		return blob
	case ObjectTag:
		tag := &Tag{
			gitObject: obj,
			cast_ptr:  (*C.git_tag)(cobj),
		}
		runtime.SetFinalizer(tag, (*Tag).Free)
		return tag
	}

	return nil
}
Example #3
0
func allocObject(cobj *C.git_object) Object {

	switch ObjectType(C.git_object_type(cobj)) {
	case OBJ_COMMIT:
		commit := &Commit{gitObject{cobj}}
		runtime.SetFinalizer(commit, (*Commit).Free)
		return commit

	case OBJ_TREE:
		tree := &Tree{gitObject{cobj}}
		runtime.SetFinalizer(tree, (*Tree).Free)
		return tree

	case OBJ_BLOB:
		blob := &Blob{gitObject{cobj}}
		runtime.SetFinalizer(blob, (*Blob).Free)
		return blob
	}

	return nil
}
Example #4
0
func (obj *Object) Type() ObjectType {
	return ObjectType(C.git_object_type(obj.git_object))
}
Example #5
0
File: object.go Project: wid/git2go
func (o gitObject) Type() ObjectType {
	return ObjectType(C.git_object_type(o.ptr))
}
Example #6
0
File: object.go Project: tmc/goit
func (o Object) Type() string {
	return C.GoString(C.git_object_type2string(C.git_object_type(o.obj)))
}