summaryrefslogtreecommitdiff
path: root/repository.go
diff options
context:
space:
mode:
authorAidan Nulman <[email protected]>2013-12-19 00:33:23 -0500
committerAidan Nulman <[email protected]>2013-12-19 00:33:23 -0500
commit19b241bd55966f495b7e32f56dc54b42a13dd0b8 (patch)
tree814feca40af628cd4eada6e0822e315c39cd592b /repository.go
parentdfe6d1ab7efa8bb480616eb5f3962989b4ac3096 (diff)
Refactor InitRepositoryWCustomOdbBackend() into component functions
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go34
1 files changed, 7 insertions, 27 deletions
diff --git a/repository.go b/repository.go
index c65bd9d..503c1b3 100644
--- a/repository.go
+++ b/repository.go
@@ -15,8 +15,6 @@ type Repository struct {
ptr *C.git_repository
}
-type InitCustomBackend func(**C.git_odb_backend) int
-
func OpenRepository(path string) (*Repository, error) {
repo := new(Repository)
@@ -47,34 +45,16 @@ func InitRepository(path string, isbare bool) (*Repository, error) {
return repo, nil
}
-func InitRepositoryWCustomOdbBackend(initStrategy InitCustomBackend, priority int) (*Repository, *Odb, error) {
- // inits
- repo := new(Repository)
- odb := new(Odb)
- backend := new(OdbBackend)
-
- // wrap routine w/abstract function
- ret := C.git_odb_new(&odb.ptr)
- if ret >= 0 {
- ret = C.git_repository_wrap_odb(&repo.ptr, odb.ptr)
- }
-
- if ret >= 0 {
- ret = C.int(initStrategy(&backend.ptr))
- }
+func InitRepositoryByWrapOdb(odb *Odb) (repo *Repository, err error) {
+ repo = new(Repository)
- if ret >= 0 {
- ret = C.git_odb_add_backend(odb.ptr, backend.ptr, C.int(priority))
+ ret := C.git_repository_wrap_odb(&repo.ptr, odb.ptr)
+ if ret < 0 {
+ return nil, LastError()
}
- // cleanup and return
- if ret < 0 {
- return nil, nil, LastError()
- }
-
- runtime.SetFinalizer(repo, (*Repository).Free)
- runtime.SetFinalizer(odb, (*Odb).Free)
- return repo, odb, nil
+ runtime.SetFinalizer(repo, (*Repository).Free)
+ return
}
func (v *Repository) Free() {