diff options
| author | Aidan Nulman <[email protected]> | 2013-12-17 18:46:25 -0500 |
|---|---|---|
| committer | Aidan Nulman <[email protected]> | 2013-12-17 18:46:25 -0500 |
| commit | 66dfbbf5399182d4b307a236042a845ca7a1ed15 (patch) | |
| tree | 6a77d163313468afd8643340671d1555606c0d30 | |
| parent | 625ffd022e2c39f3820543cc1239deeb21837266 (diff) | |
add function to init repos w/custom odb backends
| -rw-r--r-- | repository.go | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/repository.go b/repository.go index 5540a0c..6dbe386 100644 --- a/repository.go +++ b/repository.go @@ -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) |
