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.
This change adds the Shutdown() method, so that the library can be
cleanly shut down. This helps significanly reduce the amount of noise in
the leak detector.
I've added an additional constant with the correct spelling. I did this
rather than removing the existing constant to avoid breaking existing
code with the misspelled name.
CGO can perform variable substitution in the directives, so we don't
need to use a script to set up the variables; we can let the go tool do
it for us.
Go calling C is inherently multi-threaded. If libgit2 cannot handle
threading, then we're going to crash at some random point. Crash right
at the start so we know what's happening.
As the Go runtime can move stacks at any point and the C code runs
concurrently with the rest of the system, we cannot assume that the
payloads we give to the C code will stay valid for any particular
duration.
We must therefore give the C code handles which we can then look up in
our own list when the callbacks get called.
With libgit2 v0.22 released, we can expect its API and ABI to remain
stable when installed on the system.
Linking dynamically allows us to use the go tool alone to build and
install the package.
The cgo directives let us do a lot more than I previously thought, so we
can use this to make the building process of git2go go through the go
tool directly rather than via the script.
libgit2 still needs to be built manually, so we do still require make,
but only for building libgit2. Once that's built, any modifications to
git2go's own code can be built with
go build
While Go will assign the correct type to a const block when it
auto-creates the values, assigning makes the const be typeless and will
only gain it in each particular use.
Make each constant in the blocks have an assigned type.
Build in libgit2 statically into git2go by default, removing the need
for the right version to be available as a shared object.
We do still need to link dynamically against OpenSSL and LibSSH2.
Go already has all the necessary pieces for encoding and decoding hex
strings. Using them let's us avoid going into C land.
Benchmarks show this takes about half the time as using libgit2's
functions.
This is the most common way of having an id that's not in Oid form, so
let's make it the "default" and rename to NewOidFromBytes() the one that
takes []byte.
There is no need for a struct with a single field. An Oid is 20 bytes
which hold the binary representation of the hash, so let's use that
directly. Go lets us have methods on this new type just the same.