libgit2/git2go — pull request #138 by sqs (2014-11-18 13:25:29+00:00)
Title: Add script for checking thread locks in funcs that call MakeGitError

This PR adds script/check-MakeGitError-thread-lock.go, which checks for funcs that call MakeGitError and that don't lock the OS thread. Its implementation is a simple `string.Contains` check on each `*ast.FuncDecl`. It also adds this script to `make test`.

The current output is:

```
28 non-thread-locked calls to MakeGitError found. To fix, add the following to each func below that calls MakeGitError, before the cgo call that might produce the error:

runtime.LockOSThread()
defer runtime.UnlockOSThread()

Patch at diff.go:261
DefaultDiffOptions at diff.go:326
DiffTreeToTree at diff.go:377
DiffTreeToWorkdir at diff.go:430
MergeHeadFromFetchHead at merge.go:33
MergeHeadFromId at merge.go:50
MergeHeadFromRef at merge.go:61
DefaultMergeOptions at merge.go:99
SetInt32 at config.go:234
Next at config.go:350
NewOdb at odb.go:25
AddBackend at odb.go:42
ForEach at odb.go:107
NewReadStream at odb.go:141
NewWriteStream at odb.go:155
Read at odb.go:206
Write at odb.go:237
Close at odb.go:252
NewRepositoryWrapOdb at repository.go:72
CreateTag at repository.go:373
ListRemotes at remote.go:250
Fetch at remote.go:543
Ls at remote.go:587
ForEach at packbuilder.go:129
NewRefdb at refdb.go:23
SetBackend at refdb.go:40
Next at reference.go:295
String at patch.go:38
```

Ref https://github.com/libgit2/git2go/issues/137