summaryrefslogtreecommitdiff
path: root/repository.go
diff options
context:
space:
mode:
authorAidan Nulman <[email protected]>2013-12-18 17:25:54 -0500
committerAidan Nulman <[email protected]>2013-12-18 17:25:54 -0500
commitdfe6d1ab7efa8bb480616eb5f3962989b4ac3096 (patch)
tree22c9655e9a5d38f7daa3da66c81788a9016e7b04 /repository.go
parent66dfbbf5399182d4b307a236042a845ca7a1ed15 (diff)
Stop assuming ODB backend includes wrapping routine; wrap in git2go instead
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go27
1 files changed, 20 insertions, 7 deletions
diff --git a/repository.go b/repository.go
index 6dbe386..c65bd9d 100644
--- a/repository.go
+++ b/repository.go
@@ -15,7 +15,7 @@ type Repository struct {
ptr *C.git_repository
}
-type InitCustomBackend func(**C.git_repository, **C.git_odb) int
+type InitCustomBackend func(**C.git_odb_backend) int
func OpenRepository(path string) (*Repository, error) {
repo := new(Repository)
@@ -47,18 +47,31 @@ func InitRepository(path string, isbare bool) (*Repository, error) {
return repo, nil
}
-func InitRepositoryWCustomOdbBackend(initStrategy InitCustomBackend) (*Repository, *Odb, error) {
- // init return vars
- repo := new(Repository)
+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))
+ }
- // run initStrategy abstract function
- ret := initStrategy(&repo.ptr, &odb.ptr)
+ if ret >= 0 {
+ ret = C.git_odb_add_backend(odb.ptr, backend.ptr, C.int(priority))
+ }
+
+ // cleanup and return
if ret < 0 {
return nil, nil, LastError()
}
- // cleanup and return
runtime.SetFinalizer(repo, (*Repository).Free)
runtime.SetFinalizer(odb, (*Odb).Free)
return repo, odb, nil