### What this change is doing?
This change aims to enable us to set the `VENDORED_PATH` as an environment variable and failback to the default value if the environment variable is not set. Thus, this change should not break current behavior.
### Why we need this?
This will enable using the script to build libgit2 form source code downloaded manually.
Example:
```sh
LIBGIT2_VER="1.0.1"
DOWNLOAD_URL="https://codeload.github.com/libgit2/libgit2/tar.gz/v${LIBGIT2_VER}""
LIBGIT2_PATH="${HOME}/libgit2-${LIBGIT2_VER}"
wget -O "${LIBGIT2_PATH}.tar.gz" "$DOWNLOAD_URL"
tar -xzvf "${LIBGIT2_PATH}.tar.gz"
VENDORED_PATH=$LIBGIT2_PATH sh ./script/build-libgit2.sh --static
```
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.
The `recursion_limit` merge option provided by libgit2 is currently not
exposed and thus inaccessible to Git2Go users. Let's expose it to let
users control creation of recursive merge bases.
This PR adds
- The ability to apply a Diff object to the repo
- Support for git_apply_hunk_cb and git_apply_delta_cb callbacks in options for applying the diffs
- The ability to import a diff from a raw buffer (for example, one exported by ToBuf) into a Diff object associated with the repo
- Tests for the above
This change adds:
* `tag.yml`: Creates a new tag every time the master or a release branch
is pushed.
* `backport.yml`: Creates a cherry-pick in older release branches to
keep them up to date with little cost.
This change:
* Builds the library with Go 1.14, too.
* Builds the non-legacy tests with Ubuntu Focal (20.04).
* Adds testing for system-wide libraries, both static and dynamic
versions.
* Fixes a typo in the README.
Upstream libgit2 has migrated to use the GNUInstallDirs module to decide
where things will be installed to by default. While it improves
consistency with the host system, we're not really after that when
building the vendored libgit2 library, and in fact libgit2.{a,pc} may
now be installed into a different directory than before as it started to
depend on the host platform.
Fix this by explicitly specifying that we want the library and pkgconfig
file to be installed into a plain "lib/" directory.
Prior to this change you could not specifiy proxy options on the
FetchOptions struct, which made it impossible to specify a proxy for an
initial clone. This change adds the ProxyOptions to the FetchOptions
struct so you can go through a proxy when cloning.
This change allows to link the system version of libgit2 statically.
Since `-tags static` is already used for the bundled version of the
library and to avoid breaking old workflows, `-tags
static,system_libgit2` is now used to select that.
This means that the valid combinations are:
| Flag | Effect |
|-------------------------------|-----------------------------------------------|
| _No flags_ | Dynamically-linked against the system libgit2 |
| `-tags static,system_libgit2` | Statically-linked against the system libgit2 |
| `-tags static` | Statically-linked against the bundled libgit2 |
Note that there is no way to express dynamically linking against the
bundled libgit2 because that makes very little sense, since the binaries
wouldn't be able to be distributed. If that's still desired, the
`PKG_CONFIG_PATH` environment variable can set before building the code.
[`Makefile`](https://github.com/libgit2/git2go/blob/master/Makefile) has
an example of how it is used in the CI.
This change makes the DiffNotifyCallback always use an "unowned"
*git.Diff that does _not_ run the finalizer. Since the underlying
git_diff object is still owned by libgit2, we shouldn't be calling
Diff.Free() on it, even by accident, since that would cause a whole lot
of undefined behavior.
Now instead of storing a reference to a *git.Diff in the intermediate
state while the diff operation is being done, create a brand new
*git.Diff for every callback invocation, and only create a fully-owned
*git.Diff when the diff operation is done and the ownership is
transfered to Go.
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.
This change removes the `LIB_INSTALL_DIR` and `INCLUDE_INSTALL_DIR` from
the `script/build-libgit2.sh` script, since they are now unneeded and
just print a warning if they are used.
It is not Go idiomatic to put Get into the getter's name.
https: //golang.org/doc/effective_go.html#Getters
Co-Authored-By: lhchavez <lhchavez@users.noreply.github.com>
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.
This change adds Cred.Free() and finalizers to prevent memory leaks. It
also makes the interface for Cred more idiomatic and return actual
errors intead of ints.
`repository.LookupXxx()` allocate new go `Object`s that have a reference
to a `C.git_object`. Those are then duplicated with `git_object_dup()`,
so the original `Object`s linger unnecessarily until the Go GC kicks in.
This change explicitly calls `Free()` on the originals to avoid
unnecessary accumulation of garbage.