From 8c631b0c25c8de616afa2fd89378299c9d9a1439 Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Sat, 6 Dec 2014 02:44:57 +0100 Subject: Add missing thread locking --- diff.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'diff.go') diff --git a/diff.go b/diff.go index 9ce275c..d7d8118 100644 --- a/diff.go +++ b/diff.go @@ -287,6 +287,9 @@ func (diff *Diff) Patch(deltaIndex int) (*Patch, error) { } var patchPtr *C.git_patch + runtime.LockOSThread() + defer runtime.UnlockOSThread() + ecode := C.git_patch_from_diff(&patchPtr, diff.ptr, C.size_t(deltaIndex)) if ecode < 0 { return nil, MakeGitError(ecode) @@ -348,6 +351,10 @@ type DiffOptions struct { func DefaultDiffOptions() (DiffOptions, error) { opts := C.git_diff_options{} + + runtime.LockOSThread() + defer runtime.UnlockOSThread() + ecode := C.git_diff_init_options(&opts, C.GIT_DIFF_OPTIONS_VERSION) if ecode < 0 { return DiffOptions{}, MakeGitError(ecode) @@ -487,6 +494,9 @@ func (v *Repository) DiffTreeToTree(oldTree, newTree *Tree, opts *DiffOptions) ( } } + runtime.LockOSThread() + defer runtime.UnlockOSThread() + ecode := C.git_diff_tree_to_tree(&diffPtr, v.ptr, oldPtr, newPtr, copts) if ecode < 0 { return nil, MakeGitError(ecode) @@ -536,6 +546,9 @@ func (v *Repository) DiffTreeToWorkdir(oldTree *Tree, opts *DiffOptions) (*Diff, } } + runtime.LockOSThread() + defer runtime.UnlockOSThread() + ecode := C.git_diff_tree_to_workdir(&diffPtr, v.ptr, oldPtr, copts) if ecode < 0 { return nil, MakeGitError(ecode) -- cgit v1.2.3