diff --git a/checkout.go b/checkout.go index f4c1d4e..63637e2 100644 --- a/checkout.go +++ b/checkout.go @@ -9,7 +9,6 @@ git_checkout_opts git_checkout_opts_init() { */ import "C" import ( - "runtime" "os" ) @@ -60,9 +59,6 @@ func (v *Repository) Checkout(opts *CheckoutOpts) error { var copts C.git_checkout_opts populateCheckoutOpts(&copts, opts) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_checkout_head(v.ptr, &copts) if ret < 0 { return LastError() @@ -76,9 +72,6 @@ func (v *Repository) CheckoutIndex(index *Index, opts *CheckoutOpts) error { var copts C.git_checkout_opts populateCheckoutOpts(&copts, opts) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_checkout_index(v.ptr, index.ptr, &copts) if ret < 0 { return LastError() diff --git a/commit.go b/commit.go index 498669e..cacaa33 100644 --- a/commit.go +++ b/commit.go @@ -9,9 +9,8 @@ extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr); import "C" import ( - "runtime" - "time" "unsafe" + "time" ) // Commit @@ -26,9 +25,6 @@ func (c Commit) Message() string { func (c Commit) Tree() (*Tree, error) { var ptr *C.git_object - runtime.LockOSThread() - defer runtime.UnlockOSThread() - err := C.git_commit_tree(&ptr, c.ptr) if err < 0 { return nil, LastError() @@ -52,13 +48,12 @@ func (c Commit) Committer() *Signature { } func (c *Commit) Parent(n uint) *Commit { - var cobj *C.git_object - ret := C.git_commit_parent(&cobj, c.ptr, C.uint(n)) + par := &Commit{} + ret := C.git_commit_parent(&par.ptr, c.ptr, C.uint(n)) if ret != 0 { return nil } - - return allocObject(cobj).(*Commit) + return par } func (c *Commit) ParentId(n uint) *Oid { @@ -90,10 +85,10 @@ func newSignatureFromC(sig *C.git_signature) *Signature { // the offset in mintes, which is what git wants func (v *Signature) Offset() int { _, offset := v.When.Zone() - return offset / 60 + return offset/60 } -func (sig *Signature) toC() *C.git_signature { +func (sig *Signature) toC() (*C.git_signature) { var out *C.git_signature name := C.CString(sig.Name) diff --git a/config.go b/config.go index 2aa073a..dcad2a7 100644 --- a/config.go +++ b/config.go @@ -6,7 +6,6 @@ package git */ import "C" import ( - "runtime" "unsafe" ) @@ -19,9 +18,6 @@ func (c *Config) LookupInt32(name string) (v int32, err error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_config_get_int32(&out, c.ptr, cname) if ret < 0 { return 0, LastError() @@ -35,9 +31,6 @@ func (c *Config) LookupInt64(name string) (v int64, err error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_config_get_int64(&out, c.ptr, cname) if ret < 0 { return 0, LastError() @@ -51,9 +44,6 @@ func (c *Config) LookupString(name string) (v string, err error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_config_get_string(&ptr, c.ptr, cname) if ret < 0 { return "", LastError() @@ -69,9 +59,6 @@ func (c *Config) Set(name, value string) (err error) { cvalue := C.CString(value) defer C.free(unsafe.Pointer(cvalue)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_config_set_string(c.ptr, cname, cvalue) if ret < 0 { return LastError() @@ -79,8 +66,3 @@ func (c *Config) Set(name, value string) (err error) { return nil } - -func (c *Config) Free() { - runtime.SetFinalizer(c, nil) - C.git_config_free(c.ptr) -} diff --git a/git.go b/git.go index 28196c8..c663d2e 100644 --- a/git.go +++ b/git.go @@ -9,9 +9,8 @@ import "C" import ( "bytes" "errors" - "runtime" - "unsafe" "strings" + "unsafe" ) const ( @@ -58,9 +57,6 @@ func NewOidFromString(s string) (*Oid, error) { cs := C.CString(s) defer C.free(unsafe.Pointer(cs)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - if C.git_oid_fromstr(o.toC(), cs) < 0 { return nil, LastError() } @@ -93,7 +89,7 @@ func (oid *Oid) Equal(oid2 *Oid) bool { } func (oid *Oid) IsZero() bool { - for _, a := range(oid.bytes) { + for _, a := range oid.bytes { if a != '0' { return false } @@ -113,10 +109,6 @@ func ShortenOids(ids []*Oid, minlen int) (int, error) { defer C.git_oid_shorten_free(shorten) var ret C.int - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - for _, id := range ids { buf := make([]byte, 41) C.git_oid_fmt((*C.char)(unsafe.Pointer(&buf[0])), id.toC()) @@ -131,10 +123,10 @@ func ShortenOids(ids []*Oid, minlen int) (int, error) { type GitError struct { Message string - Code int + Code int } -func (e GitError) Error() string{ +func (e GitError) Error() string { return e.Message } @@ -147,14 +139,14 @@ func LastError() error { } func cbool(b bool) C.int { - if (b) { + if b { return C.int(1) } return C.int(0) } func ucbool(b bool) C.uint { - if (b) { + if b { return C.uint(1) } return C.uint(0) @@ -167,16 +159,13 @@ func Discover(start string, across_fs bool, ceiling_dirs []string) (string, erro cstart := C.CString(start) defer C.free(unsafe.Pointer(cstart)) - retpath := (*C.char)(C.malloc(C.GIT_PATH_MAX)) - defer C.free(unsafe.Pointer(retpath)) + retpath := (*C.git_buf)(C.malloc(C.GIT_PATH_MAX)) + defer C.git_buf_free(retpath) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - r := C.git_repository_discover(retpath, C.GIT_PATH_MAX, cstart, cbool(across_fs), ceildirs) + r := C.git_repository_discover(retpath, cstart, cbool(across_fs), ceildirs) if r == 0 { - return C.GoString(retpath), nil + return C.GoString(retpath.ptr), nil } return "", LastError() diff --git a/index.go b/index.go index ac5148c..4a69c1e 100644 --- a/index.go +++ b/index.go @@ -24,9 +24,6 @@ func (v *Index) AddByPath(path string) error { cstr := C.CString(path) defer C.free(unsafe.Pointer(cstr)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_index_add_bypath(v.ptr, cstr) if ret < 0 { return LastError() @@ -37,10 +34,6 @@ func (v *Index) AddByPath(path string) error { func (v *Index) WriteTree() (*Oid, error) { oid := new(Oid) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_index_write_tree(oid.toC(), v.ptr) if ret < 0 { return nil, LastError() diff --git a/odb.go b/odb.go index 638ef74..eaa7872 100644 --- a/odb.go +++ b/odb.go @@ -25,10 +25,6 @@ func (v *Odb) Exists(oid *Oid) bool { func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) { oid = new(Oid) hdr := (*reflect.SliceHeader)(unsafe.Pointer(&data)) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_odb_write(oid.toC(), v.ptr, unsafe.Pointer(hdr.Data), C.size_t(hdr.Len), C.git_otype(otype)) if ret < 0 { @@ -40,10 +36,6 @@ func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) { func (v *Odb) Read(oid *Oid) (obj *OdbObject, err error) { obj = new(OdbObject) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_odb_read(&obj.ptr, v.ptr, oid.toC()) if ret < 0 { return nil, LastError() diff --git a/packbuilder.go b/packbuilder.go index 333f183..c57b0d4 100644 --- a/packbuilder.go +++ b/packbuilder.go @@ -22,10 +22,6 @@ type Packbuilder struct { func (repo *Repository) NewPackbuilder() (*Packbuilder, error) { builder := &Packbuilder{} - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_packbuilder_new(&builder.ptr, repo.ptr) if ret != 0 { return nil, LastError() @@ -42,10 +38,6 @@ func (pb *Packbuilder) Free() { func (pb *Packbuilder) Insert(id *Oid, name string) error { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_packbuilder_insert(pb.ptr, id.toC(), cname) if ret != 0 { return LastError() @@ -54,9 +46,6 @@ func (pb *Packbuilder) Insert(id *Oid, name string) error { } func (pb *Packbuilder) InsertCommit(id *Oid) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_packbuilder_insert_commit(pb.ptr, id.toC()) if ret != 0 { return LastError() @@ -65,9 +54,6 @@ func (pb *Packbuilder) InsertCommit(id *Oid) error { } func (pb *Packbuilder) InsertTree(id *Oid) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_packbuilder_insert_tree(pb.ptr, id.toC()) if ret != 0 { return LastError() @@ -82,10 +68,6 @@ func (pb *Packbuilder) ObjectCount() uint32 { func (pb *Packbuilder) WriteToFile(name string, mode os.FileMode) error { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_packbuilder_write(pb.ptr, cname, C.uint(mode.Perm()), nil, nil) if ret != 0 { return LastError() diff --git a/reference.go b/reference.go index 8e33354..8060146 100644 --- a/reference.go +++ b/reference.go @@ -11,6 +11,7 @@ import ( ) type ReferenceType int + const ( ReferenceSymbolic ReferenceType = C.GIT_REF_SYMBOLIC ReferenceOid = C.GIT_REF_OID @@ -27,15 +28,19 @@ func newReferenceFromC(ptr *C.git_reference) *Reference { return ref } -func (v *Reference) SetSymbolicTarget(target string) (*Reference, error) { +func (v *Reference) SetSymbolicTarget(target string, sig *Signature, msg string) (*Reference, error) { var ptr *C.git_reference + ctarget := C.CString(target) defer C.free(unsafe.Pointer(ctarget)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() + csig := sig.toC() + defer C.free(unsafe.Pointer(csig)) - ret := C.git_reference_symbolic_set_target(&ptr, v.ptr, ctarget) + cmsg := C.CString(msg) + defer C.free(unsafe.Pointer(cmsg)) + + ret := C.git_reference_symbolic_set_target(&ptr, v.ptr, ctarget, csig, cmsg) if ret < 0 { return nil, LastError() } @@ -43,13 +48,16 @@ func (v *Reference) SetSymbolicTarget(target string) (*Reference, error) { return newReferenceFromC(ptr), nil } -func (v *Reference) SetTarget(target *Oid) (*Reference, error) { +func (v *Reference) SetTarget(target *Oid, sig *Signature, msg string) (*Reference, error) { var ptr *C.git_reference - runtime.LockOSThread() - defer runtime.UnlockOSThread() + csig := sig.toC() + defer C.free(unsafe.Pointer(csig)) - ret := C.git_reference_set_target(&ptr, v.ptr, target.toC()) + cmsg := C.CString(msg) + defer C.free(unsafe.Pointer(cmsg)) + + ret := C.git_reference_set_target(&ptr, v.ptr, target.toC(), csig, cmsg) if ret < 0 { return nil, LastError() } @@ -60,9 +68,6 @@ func (v *Reference) SetTarget(target *Oid) (*Reference, error) { func (v *Reference) Resolve() (*Reference, error) { var ptr *C.git_reference - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_reference_resolve(&ptr, v.ptr) if ret < 0 { return nil, LastError() @@ -76,9 +81,6 @@ func (v *Reference) Rename(name string, force bool) (*Reference, error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_reference_rename(&ptr, v.ptr, cname, cbool(force)) if ret < 0 { @@ -102,9 +104,6 @@ func (v *Reference) SymbolicTarget() string { } func (v *Reference) Delete() error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_reference_delete(v.ptr) if ret < 0 { @@ -135,10 +134,6 @@ type ReferenceIterator struct { // NewReferenceIterator creates a new iterator over reference names func (repo *Repository) NewReferenceIterator() (*ReferenceIterator, error) { var ptr *C.git_reference_iterator - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_reference_iterator_new(&ptr, repo.ptr) if ret < 0 { return nil, LastError() @@ -156,10 +151,6 @@ func (repo *Repository) NewReferenceIteratorGlob(glob string) (*ReferenceIterato cstr := C.CString(glob) defer C.free(unsafe.Pointer(cstr)) var ptr *C.git_reference_iterator - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_reference_iterator_glob_new(&ptr, repo.ptr, cstr) if ret < 0 { return nil, LastError() @@ -174,10 +165,6 @@ func (repo *Repository) NewReferenceIteratorGlob(glob string) (*ReferenceIterato // the returned error is git.ErrIterOver func (v *ReferenceIterator) NextName() (string, error) { var ptr *C.char - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_reference_next_name(&ptr, v.ptr) if ret == ITEROVER { return "", ErrIterOver diff --git a/reference_test.go b/reference_test.go index f955a2c..ab62522 100644 --- a/reference_test.go +++ b/reference_test.go @@ -14,7 +14,14 @@ func TestRefModification(t *testing.T) { commitId, treeId := seedTestRepo(t, repo) - _, err := repo.CreateReference("refs/tags/tree", treeId, true) + loc, err := time.LoadLocation("Europe/Berlin") + checkFatal(t, err) + sig := &Signature{ + Name: "Rand Om Hacker", + Email: "random@hacker.com", + When: time.Date(2013, 03, 06, 14, 30, 0, 0, loc), + } + _, err = repo.CreateReference("refs/tags/tree", treeId, true, sig, "testTreeTag") checkFatal(t, err) tag, err := repo.LookupReference("refs/tags/tree") @@ -78,13 +85,13 @@ func TestIterator(t *testing.T) { commitId, err := repo.CreateCommit("HEAD", sig, sig, message, tree) checkFatal(t, err) - _, err = repo.CreateReference("refs/heads/one", commitId, true) + _, err = repo.CreateReference("refs/heads/one", commitId, true, sig, "headOne") checkFatal(t, err) - _, err = repo.CreateReference("refs/heads/two", commitId, true) + _, err = repo.CreateReference("refs/heads/two", commitId, true, sig, "headTwo") checkFatal(t, err) - _, err = repo.CreateReference("refs/heads/three", commitId, true) + _, err = repo.CreateReference("refs/heads/three", commitId, true, sig, "headThree") checkFatal(t, err) iter, err := repo.NewReferenceIterator() @@ -108,7 +115,6 @@ func TestIterator(t *testing.T) { t.Fatal("Iteration not over") } - sort.Strings(list) compareStringList(t, expected, list) @@ -129,7 +135,6 @@ func TestIterator(t *testing.T) { t.Fatalf("Wrong number of references returned %v", count) } - // test the channel iteration list = []string{} iter, err = repo.NewReferenceIterator() diff --git a/repository.go b/repository.go index 3a9068d..31a2d05 100644 --- a/repository.go +++ b/repository.go @@ -21,9 +21,6 @@ func OpenRepository(path string) (*Repository, error) { cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_repository_open(&repo.ptr, cpath) if ret < 0 { return nil, LastError() @@ -39,9 +36,6 @@ func InitRepository(path string, isbare bool) (*Repository, error) { cpath := C.CString(path) defer C.free(unsafe.Pointer(cpath)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_repository_init(&repo.ptr, cpath, ucbool(isbare)) if ret < 0 { return nil, LastError() @@ -59,24 +53,16 @@ func (v *Repository) Free() { func (v *Repository) Config() (*Config, error) { config := new(Config) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_repository_config(&config.ptr, v.ptr) if ret < 0 { return nil, LastError() } - runtime.SetFinalizer(config, (*Config).Free) return config, nil } func (v *Repository) Index() (*Index, error) { var ptr *C.git_index - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_repository_index(&ptr, v.ptr) if ret < 0 { return nil, LastError() @@ -87,10 +73,6 @@ func (v *Repository) Index() (*Index, error) { func (v *Repository) lookupType(oid *Oid, t ObjectType) (Object, error) { var ptr *C.git_object - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_object_lookup(&ptr, v.ptr, oid.toC(), C.git_otype(t)) if ret < 0 { return nil, LastError() @@ -135,9 +117,6 @@ func (v *Repository) LookupReference(name string) (*Reference, error) { defer C.free(unsafe.Pointer(cname)) var ptr *C.git_reference - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ecode := C.git_reference_lookup(&ptr, v.ptr, cname) if ecode < 0 { return nil, LastError() @@ -146,15 +125,19 @@ func (v *Repository) LookupReference(name string) (*Reference, error) { return newReferenceFromC(ptr), nil } -func (v *Repository) CreateReference(name string, oid *Oid, force bool) (*Reference, error) { +func (v *Repository) CreateReference(name string, oid *Oid, force bool, sig *Signature, msg string) (*Reference, error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) + + csig := sig.toC() + defer C.free(unsafe.Pointer(csig)) + + cmsg := C.CString(msg) + defer C.free(unsafe.Pointer(cmsg)) + var ptr *C.git_reference - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - ecode := C.git_reference_create(&ptr, v.ptr, cname, oid.toC(), cbool(force)) + ecode := C.git_reference_create(&ptr, v.ptr, cname, oid.toC(), cbool(force), csig, cmsg) if ecode < 0 { return nil, LastError() } @@ -162,17 +145,22 @@ func (v *Repository) CreateReference(name string, oid *Oid, force bool) (*Refere return newReferenceFromC(ptr), nil } -func (v *Repository) CreateSymbolicReference(name, target string, force bool) (*Reference, error) { +func (v *Repository) CreateSymbolicReference(name, target string, force bool, sig *Signature, msg string) (*Reference, error) { cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) + ctarget := C.CString(target) defer C.free(unsafe.Pointer(ctarget)) + + csig := sig.toC() + defer C.free(unsafe.Pointer(csig)) + + cmsg := C.CString(msg) + defer C.free(unsafe.Pointer(cmsg)) + var ptr *C.git_reference - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - ecode := C.git_reference_symbolic_create(&ptr, v.ptr, cname, ctarget, cbool(force)) + ecode := C.git_reference_symbolic_create(&ptr, v.ptr, cname, ctarget, cbool(force), csig, cmsg) if ecode < 0 { return nil, LastError() } @@ -182,10 +170,6 @@ func (v *Repository) CreateSymbolicReference(name, target string, force bool) (* func (v *Repository) Walk() (*RevWalk, error) { walk := new(RevWalk) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ecode := C.git_revwalk_new(&walk.ptr, v.ptr) if ecode < 0 { return nil, LastError() @@ -226,9 +210,6 @@ func (v *Repository) CreateCommit( committerSig := committer.toC() defer C.git_signature_free(committerSig) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_commit_create( oid.toC(), v.ptr, cref, authorSig, committerSig, @@ -248,10 +229,6 @@ func (v *Odb) Free() { func (v *Repository) Odb() (odb *Odb, err error) { odb = new(Odb) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - if ret := C.git_repository_odb(&odb.ptr, v.ptr); ret < 0 { return nil, LastError() } @@ -276,9 +253,6 @@ func (repo *Repository) SetWorkdir(workdir string, updateGitlink bool) error { cstr := C.CString(workdir) defer C.free(unsafe.Pointer(cstr)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - if C.git_repository_set_workdir(repo.ptr, cstr, cbool(updateGitlink)) < 0 { return LastError() } @@ -287,14 +261,9 @@ func (repo *Repository) SetWorkdir(workdir string, updateGitlink bool) error { func (v *Repository) TreeBuilder() (*TreeBuilder, error) { bld := new(TreeBuilder) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - if ret := C.git_treebuilder_create(&bld.ptr, nil); ret < 0 { return nil, LastError() } - runtime.SetFinalizer(bld, (*TreeBuilder).Free) bld.repo = v return bld, nil @@ -305,10 +274,6 @@ func (v *Repository) RevparseSingle(spec string) (Object, error) { defer C.free(unsafe.Pointer(cspec)) var ptr *C.git_object - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ecode := C.git_revparse_single(&ptr, v.ptr, cspec) if ecode < 0 { return nil, LastError() diff --git a/submodule.go b/submodule.go index 48ea151..903d784 100644 --- a/submodule.go +++ b/submodule.go @@ -8,7 +8,6 @@ extern int _go_git_visit_submodule(git_repository *repo, void *fct); */ import "C" import ( - "runtime" "unsafe" ) @@ -56,6 +55,14 @@ const ( SubmoduleStatusWdUntracked = C.GIT_SUBMODULE_STATUS_WD_UNTRACKED ) +type SubmoduleRecurse int + +const ( + SubmoduleRecurseNo SubmoduleRecurse = C.GIT_SUBMODULE_RECURSE_NO + SubmoduleRecurseYes = C.GIT_SUBMODULE_RECURSE_YES + SubmoduleRecurseOndemand = C.GIT_SUBMODULE_RECURSE_ONDEMAND +) + func SubmoduleStatusIsUnmodified(status int) bool { o := SubmoduleStatus(status) & ^(SubmoduleStatusInHead | SubmoduleStatusInIndex | SubmoduleStatusInConfig | SubmoduleStatusInWd) @@ -67,10 +74,6 @@ func (repo *Repository) LookupSubmodule(name string) (*Submodule, error) { defer C.free(unsafe.Pointer(cname)) sub := new(Submodule) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_lookup(&sub.ptr, repo.ptr, cname) if ret < 0 { return nil, LastError() @@ -89,9 +92,6 @@ func SubmoduleVisitor(csub unsafe.Pointer, name string, cfct unsafe.Pointer) int } func (repo *Repository) ForeachSubmodule(cbk SubmoduleCbk) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C._go_git_visit_submodule(repo.ptr, unsafe.Pointer(&cbk)) if ret < 0 { return LastError() @@ -106,10 +106,6 @@ func (repo *Repository) AddSubmodule(url, path string, use_git_link bool) (*Subm defer C.free(unsafe.Pointer(cpath)) sub := new(Submodule) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_add_setup(&sub.ptr, repo.ptr, curl, cpath, cbool(use_git_link)) if ret < 0 { return nil, LastError() @@ -118,9 +114,6 @@ func (repo *Repository) AddSubmodule(url, path string, use_git_link bool) (*Subm } func (sub *Submodule) FinalizeAdd() error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_add_finalize(sub.ptr) if ret < 0 { return LastError() @@ -129,9 +122,6 @@ func (sub *Submodule) FinalizeAdd() error { } func (sub *Submodule) AddToIndex(write_index bool) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_add_to_index(sub.ptr, cbool(write_index)) if ret < 0 { return LastError() @@ -140,9 +130,6 @@ func (sub *Submodule) AddToIndex(write_index bool) error { } func (sub *Submodule) Save() error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_save(sub.ptr) if ret < 0 { return LastError() @@ -175,9 +162,6 @@ func (sub *Submodule) SetUrl(url string) error { curl := C.CString(url) defer C.free(unsafe.Pointer(curl)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_set_url(sub.ptr, curl) if ret < 0 { return LastError() @@ -236,11 +220,8 @@ func (sub *Submodule) FetchRecurseSubmodules() bool { return true } -func (sub *Submodule) SetFetchRecurseSubmodules(v bool) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - - ret := C.git_submodule_set_fetch_recurse_submodules(sub.ptr, cbool(v)) +func (sub *Submodule) SetFetchRecurseSubmodules(recurse SubmoduleRecurse) error { + ret := C.git_submodule_set_fetch_recurse_submodules(sub.ptr, C.git_submodule_recurse_t(recurse)) if ret < 0 { return LastError() } @@ -248,9 +229,6 @@ func (sub *Submodule) SetFetchRecurseSubmodules(v bool) error { } func (sub *Submodule) Init(overwrite bool) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_init(sub.ptr, cbool(overwrite)) if ret < 0 { return LastError() @@ -259,9 +237,6 @@ func (sub *Submodule) Init(overwrite bool) error { } func (sub *Submodule) Sync() error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_sync(sub.ptr) if ret < 0 { return LastError() @@ -271,10 +246,6 @@ func (sub *Submodule) Sync() error { func (sub *Submodule) Open() (*Repository, error) { repo := new(Repository) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_open(&repo.ptr, sub.ptr) if ret < 0 { return nil, LastError() @@ -283,9 +254,6 @@ func (sub *Submodule) Open() (*Repository, error) { } func (sub *Submodule) Reload() error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_reload(sub.ptr) if ret < 0 { return LastError() @@ -294,9 +262,6 @@ func (sub *Submodule) Reload() error { } func (repo *Repository) ReloadAllSubmodules() error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_submodule_reload_all(repo.ptr) if ret < 0 { return LastError() diff --git a/tree.go b/tree.go index 8c74e5d..3abd31c 100644 --- a/tree.go +++ b/tree.go @@ -62,9 +62,6 @@ func (t Tree) EntryByPath(path string) (*TreeEntry, error) { defer C.free(unsafe.Pointer(cpath)) var entry *C.git_tree_entry - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_tree_entry_bypath(&entry, t.ptr, cpath) if ret < 0 { return nil, LastError() @@ -99,9 +96,6 @@ func CallbackGitTreeWalk(_root unsafe.Pointer, _entry unsafe.Pointer, ptr unsafe } func (t Tree) Walk(callback TreeWalkCallback) error { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - err := C._go_git_treewalk( t.ptr, C.GIT_TREEWALK_PRE, @@ -129,9 +123,6 @@ func (v *TreeBuilder) Insert(filename string, id *Oid, filemode int) (error) { cfilename := C.CString(filename) defer C.free(unsafe.Pointer(cfilename)) - runtime.LockOSThread() - defer runtime.UnlockOSThread() - err := C.git_treebuilder_insert(nil, v.ptr, cfilename, id.toC(), C.git_filemode_t(filemode)) if err < 0 { return LastError() @@ -142,10 +133,6 @@ func (v *TreeBuilder) Insert(filename string, id *Oid, filemode int) (error) { func (v *TreeBuilder) Write() (*Oid, error) { oid := new(Oid) - - runtime.LockOSThread() - defer runtime.UnlockOSThread() - err := C.git_treebuilder_write(oid.toC(), v.repo.ptr, v.ptr) if err < 0 { diff --git a/walk.go b/walk.go index 6979b6b..9fc4094 100644 --- a/walk.go +++ b/walk.go @@ -8,7 +8,6 @@ import "C" import ( "io" - "runtime" ) // RevWalk @@ -35,9 +34,6 @@ func (v *RevWalk) Push(id *Oid) { } func (v *RevWalk) PushHead() (err error) { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ecode := C.git_revwalk_push_head(v.ptr) if ecode < 0 { err = LastError() @@ -47,9 +43,6 @@ func (v *RevWalk) PushHead() (err error) { } func (v *RevWalk) Next(oid *Oid) (err error) { - runtime.LockOSThread() - defer runtime.UnlockOSThread() - ret := C.git_revwalk_next(oid.toC(), v.ptr) switch { case ret == ITEROVER: