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.
The library stores error information in thread-local storage, which
means we need to make sure that the Go runtime doesn't switch OS
threads between the time we call a function and th time we attempt to
retrieve the error information.
Don't name the return values, as they conflict with the names we want
inside and the types don't match what we want to have inside. We need
them to be two-way channels in the function, and then pass
unidirectional references to the different functions.
Unfortunately libgit2 sometimes returns an error without setting an
error message. Provide an alternative message instead of trying to
dereference nil.