Add a ReInit function (#647) #649

Merged
github-actions[bot] merged 1 commits from cherry-pick-279412635-release-0.27 into release-0.27 2020-09-29 17:51:32 -05:00
1 changed files with 13 additions and 0 deletions
Showing only changes of commit 86d0d53f1b - Show all commits

13
git.go
View File

@ -118,6 +118,10 @@ var (
var pointerHandles *HandleList
func init() {
initLibGit2()
}
func initLibGit2() {
pointerHandles = NewHandleList()
C.git_libgit2_init()
@ -149,6 +153,15 @@ func Shutdown() {
C.git_libgit2_shutdown()
}
// ReInit reinitializes the global state, this is useful if the effective user
// id has changed and you want to update the stored search paths for gitconfig
// files. This function frees any references to objects, so it should be called
// before any other functions are called.
func ReInit() {
Shutdown()
initLibGit2()
}
// Oid represents the id for a Git object.
type Oid [20]byte