diff options
| author | Jesse Hathaway <[email protected]> | 2020-09-29 17:42:20 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-09-29 15:42:20 -0700 |
| commit | 3c5c580d78831d10e082743f3783424b72ac9e09 (patch) | |
| tree | c89d12b9506bbeadcdff5f7a4e57544a834c377e | |
| parent | 7e726fda6ec2b5d773e5a8b54ed06378a53c0f7f (diff) | |
Add a ReInit function (#647)
libgit2 stores the lookup paths for gitconfig files in its global state.
This means that after a program changes its effective uid libgit2 will
still look for gitconfig files in the home directory of the original
uid. Expose a way to call C.git_libgit2_init so a user can reinitialize
the libgit2 global state.
| -rw-r--r-- | git.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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 |
