add function to init repos w/custom odb backends
This commit is contained in:
parent
625ffd022e
commit
66dfbbf539
|
@ -15,6 +15,8 @@ type Repository struct {
|
|||
ptr *C.git_repository
|
||||
}
|
||||
|
||||
type InitCustomBackend func(**C.git_repository, **C.git_odb) int
|
||||
|
||||
func OpenRepository(path string) (*Repository, error) {
|
||||
repo := new(Repository)
|
||||
|
||||
|
@ -45,6 +47,23 @@ func InitRepository(path string, isbare bool) (*Repository, error) {
|
|||
return repo, nil
|
||||
}
|
||||
|
||||
func InitRepositoryWCustomOdbBackend(initStrategy InitCustomBackend) (*Repository, *Odb, error) {
|
||||
// init return vars
|
||||
repo := new(Repository)
|
||||
odb := new(Odb)
|
||||
|
||||
// run initStrategy abstract function
|
||||
ret := initStrategy(&repo.ptr, &odb.ptr)
|
||||
if ret < 0 {
|
||||
return nil, nil, LastError()
|
||||
}
|
||||
|
||||
// cleanup and return
|
||||
runtime.SetFinalizer(repo, (*Repository).Free)
|
||||
runtime.SetFinalizer(odb, (*Odb).Free)
|
||||
return repo, odb, nil
|
||||
}
|
||||
|
||||
func (v *Repository) Free() {
|
||||
runtime.SetFinalizer(v, nil)
|
||||
C.git_repository_free(v.ptr)
|
||||
|
|
Loading…
Reference in New Issue