Commit Graph

896 Commits

Author SHA1 Message Date
lhchavez aae7e1b7c8 Build improvements (#707)
This change makes the test be verbose and use parallelization if
possible (when using gmake to build).

(cherry picked from commit 54afccfa0f)
2020-12-06 13:09:13 -08:00
lhchavez 2ab8583abe
Refactor all callbacks (#700) (#704)
This change is a preparation for another change that makes all callback
types return a Go error instead of an error code / an integer. That is
going to make make things a lot more idiomatic.

The reason this change is split is threefold:

a) This change is mostly mechanical and should contain no semantic
   changes.
b) This change is backwards-compatible (in the Go API compatibility
   sense of the word), and thus can be backported to all other releases.
c) It makes the other change a bit smaller and more focused on just one
   thing.

Concretely, this change makes all callbacks populate a Go error when
they fail. If the callback is invoked from the same stack as the
function to which it was passed (e.g. for `Tree.Walk`), it will preserve
the error object directly into a struct that also holds the callback
function. Otherwise if the callback is pased to one func and will be
invoked when run from another one (e.g. for `Repository.InitRebase`),
the error string is saved into the libgit2 thread-local storage and then
re-created as a `GitError`.

(cherry picked from commit 5d8eaf7e65)
2020-12-05 17:10:03 -08:00
lhchavez af81980883
Mark some symbols to be deprecated #minor (#698) (#701)
This change introduces the file deprecated.go, which contains any
constants, functions, and types that are slated to be deprecated in the
next major release.

These symbols are deprecated because they refer to old spellings in
pre-1.0 libgit2. This also makes the build be done with the
`-DDEPRECATE_HARD` flag to avoid regressions.

This, together with
[gorelease](https://godoc.org/golang.org/x/exp/cmd/gorelease)[1] should
make releases safer going forward.

1: More information about how that works at
   https://go.googlesource.com/exp/+/refs/heads/master/apidiff/README.md
(cherry picked from commit 137c05e802)
2020-12-05 11:50:28 -08:00
github-actions[bot] 8d28e2a8dd
Add ReferenceNormalizeName (#681) (#687)
(cherry picked from commit 2bd574b6bd)

Co-authored-by: Segev Finer <segev@codeocean.com>
2020-11-13 18:35:54 -08:00
github-actions[bot] 3893405679
Travis-ci: added support for ppc64le (#682) (#685)
Added power support for the travis.yml file with ppc64le. This is part of the Ubuntu distribution for ppc64le. This helps us simplify testing later when distributions are re-building and re-releasing.

(cherry picked from commit 2d639d8e49)

Co-authored-by: Devendra <devendranath.thadi3@gmail.com>
2020-11-13 16:48:16 -08:00
github-actions[bot] b00c365f50
Add GIT_BLAME_USE_MAILMAP flag (#676) (#680)
The `GIT_BLAME_USE_MAILMAP` blame option flag was introduced in libgit2 v0.28

Change type: #minor

(cherry picked from commit b46ebfab8c)

Co-authored-by: Suhaib Mujahid <suhaibmujahid@gmail.com>
2020-11-07 15:05:41 -08:00
lhchavez bd9b40fc67
CI refresh (#666) (#670)
This change:

* Makes the Travis tests only run tip, since the rest of the Go versions are better served by GitHub Actions.
* Use Go 1.15 in the CI. This has been released for a while.

(cherry picked from commit f83530b18d)
2020-11-02 18:47:12 -08:00
github-actions[bot] c18989f652
feat: Implement an option to control hash verification (#671) (#672)
Add a binding to enable/disable hash verification using the `GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION` option.

Change type: #minor

(cherry picked from commit c3664193f3)

Co-authored-by: Suhaib Mujahid <suhaibmujahid@gmail.com>
2020-11-02 18:43:15 -08:00
github-actions[bot] 2870fabe22
apply: Add bindings for git_apply_to_tree (#657) (#665)
Adds bindings to the git_apply_to_tree function that allows applying
a diff directly to a tree.

(cherry picked from commit 10d5ebf231)

Co-authored-by: Sami Hiltunen <github@hiltunen.io>
2020-10-23 05:28:43 -07:00
github-actions[bot] 6badd3d00d
Make `TestApplyDiffAddFile()` explicitly `.Free()` stuff (#661) (#664)
This change adds explicit `.Free()` calls in `TestApplyDiffAddFile()`.
It was discovered in #657 that some objects were not explicitly being
freed, so this fixes that!

(cherry picked from commit 3a4204bd93)

Co-authored-by: lhchavez <lhchavez@lhchavez.com>
2020-10-22 06:33:59 -07:00
github-actions[bot] 8b6f3d8056
repository: Implement wrappers for `git_object_lookup_prefix` (#658) (#660)
While we already have wrappers for `git_object_lookup`, there are none
yet for the prefixed variant where only the first n bytes of the OID are
used for the lookup. This commit adds them.

(cherry picked from commit 37b81b61f1)

Co-authored-by: Patrick Steinhardt <ps@pks.im>
2020-10-22 05:32:33 -07:00
github-actions[bot] b6212551e2
feat: Enable change the system install path (#653) (#655)
#### Problem:
The current `CMAKE_INSTALL_PREFIX` value for the `system` build mode is `/usr`. However, in`macOS` as an example, you cannot write to `/usr` without `sudo` permission.

#### Proposed solution:
Enable changing the value to `/usr/local` (or any other path). This change makes the script use the value of the environment variable `SYSTEM_INSTALL_PREFIX` to select the installation path.  If the variable is not set, it fallback to the path `/usr`.

(cherry picked from commit 111185838c)

Co-authored-by: Suhaib Mujahid <suhaibmujahid@gmail.com>
2020-09-30 17:31:34 -07:00
github-actions[bot] 4b27f5c430
Enable set the VENDORED_PATH for libgit2 (#650) (#651)
### 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
```

(cherry picked from commit f3a746d7b6)

Co-authored-by: Suhaib Mujahid <suhaibmujahid@gmail.com>
2020-09-30 17:16:15 -07:00
github-actions[bot] 3fcab7513d
Add a ReInit function (#647) (#648)
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.

(cherry picked from commit 3c5c580d78)

Co-authored-by: Jesse Hathaway <jesse@mbuki-mvuki.org>
2020-09-29 15:50:11 -07:00
github-actions[bot] 1cf6bf8314
merge: Expose recursion limit merge option (#642) (#643)
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.

(cherry picked from commit 7e726fda6e)

Co-authored-by: Patrick Steinhardt <ps@pks.im>
2020-09-18 06:21:56 -07:00
github-actions[bot] fb4e5911aa
Add support for creating signed commits (#626) (#640)
(cherry picked from commit 7d4453198b)

This is only a partial cherry-pick, since signing commits during a
rebase is not supported in v0.28.
2020-08-18 09:52:35 -07:00
lhchavez 4883fbe872
Fix the build (#638)
As it turns out, the CI was not enabled for the release-0.28 branch.
2020-08-18 06:35:53 -07:00
github-actions[bot] 61ea21fbd6
More diff functionality (#629) (#637)
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

(cherry picked from commit 7883ec85de)
2020-08-18 06:22:24 -07:00
github-actions[bot] a3140afde2
Add two more GitHub Actions workflows (#633) (#634)
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.

(cherry picked from commit 2ac9f4e69b)
2020-08-16 07:28:18 -07:00
lhchavez 20c6fefa56 Update libgit2 to v0.28.5 2020-08-16 07:19:20 -07:00
lhchavez fcb8a8cc3b Refresh the GitHub Actions CI (#632)
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.

(cherry picked from commit 5314951759)
2020-08-16 07:19:20 -07:00
michael boulton 19b0d4241c Fix null pointer dereference in status.ByIndex (#628)
`git_status_byindex` can return a null pointer if there is no statuses.

(cherry picked from commit fc6eaf3638)
2020-08-16 07:19:20 -07:00
Yuichi Watanabe 64c6ddb513 Add support for git_blob_is_binary (#625)
This adds IsBinary() func to Blob struct, which simply returns the result of git_blob_is_binary function.
Refs: https://libgit2.org/libgit2/#HEAD/group/blob/git_blob_is_binary
Issue: Add support for git_blob_is_binary #426

Fixes: #426
(cherry picked from commit 462ebd83e0)
2020-08-16 07:19:20 -07:00
Jesse Hathaway 6c1af418ae FetchOptions: add ability to specify ProxyOptions (#623)
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.

(cherry picked from commit b1cad11555)
2020-08-16 07:19:20 -07:00
lhchavez d5fa51db4f Revamp the ways in which the library can be built (#621)
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.

(cherry picked from commit 20a55cdf92)
2020-08-16 07:19:20 -07:00
lhchavez d6c2d12ee1 Fix a potential use-after-free in DiffNotifyCallback (#579)
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.

(cherry picked from commit c78ae57de6)
2020-08-16 07:19:20 -07:00
lhchavez decab2d988 Add a way to cleanly shut down the library (#578)
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.

(cherry picked from commit 619a9c236b)
2020-08-16 07:19:20 -07:00
lhchavez e4b04e142b Update the `README.md` to clarify some aspects of static libgit2 (#620)
This change improves the documentation surrounding libgit2 static builds
and modules.

Fixes: #618
(cherry picked from commit 9eaf4fed5f)
2020-08-16 07:19:20 -07:00
Takuji Shimokawa 496b346c97 Provide missing merge flags (#615)
This change adds two missing merge flags MergeTreeSkipREUC and MergeTreeNoRecursive.

(cherry picked from commit 33dac3d460)
2020-08-16 07:19:20 -07:00
Jesse Hathaway 354218d9bb Add support for parsing git trailers (#614)
Adds a wrapper for git_message_trailers which returns a slice of trailer
structs.

(cherry picked from commit 5241c72e6e)
2020-08-16 07:19:20 -07:00
lhchavez 7b83382e04 Merge pull request #582 from suhaibmujahid/method-rename
It is not Go idiomatic to put Get into the getter's name

(cherry picked from commit 31f877e249)
2020-08-16 07:19:20 -07:00
lhchavez b8df55f956 expose options related to caching
(cherry picked from commit 8b51d0db8e)
2020-08-16 07:19:20 -07:00
Suhaib Mujahid b2fae9430f Check nil signature
(cherry picked from commit 91d08450b6)
2020-08-16 07:19:20 -07:00
lhchavez 707a03b581 Fix SIGSEGV on double free for Cred object
This change removes the Go finalizer when passing ownership to libgit2.

Fixes: #553
(cherry picked from commit 0843b826d2)
2020-08-16 07:19:20 -07:00
Suhaib Mujahid 4681adf414 Update README.md
(cherry picked from commit 3a2102638d)
2020-08-16 07:19:20 -07:00
lhchavez 752bac6334 Update README.md
Clarifying the versions since we're using Go 1.11 module version rules now.

(cherry picked from commit 2b66c0f9e7)
2020-08-16 07:19:20 -07:00
lhchavez 84b7f45673 Add the version number to go.mod
This is the second take on trying to tag the current release with a Go
version.

(cherry picked from commit a32375a860)
2020-08-16 07:19:20 -07:00
lhchavez 1526448a89 Merge pull request #542 from slyphon/fix-error-name
Resolves issue #541 - typo in error code 'ErrAmbigious'

(cherry picked from commit 30de4b2e26)
2020-08-16 07:19:20 -07:00
lhchavez f4a3dd4cc7 Fix the DiffFlag type
This change makes the underlying type of DiffFlag be uint32 instead of
int. That makes it possible to build on 32-bit systems.

Fixes: #487
(cherry picked from commit 93c4c5b30a)
2020-08-16 07:19:20 -07:00
lhchavez 1c82797e35 Add odb.NewOdbBackendLoose()
This change adds support for odb.NewOdbBackendLoose(). This, together
with the git.Packbuilder, can do what Mempack does with a lot less
memory.

(cherry picked from commit 91946a5705)
2020-08-16 07:19:20 -07:00
lhchavez 2fe03c06e7 Add support for indexers and alternate odb packfiles
This allows for implementations of git servers written in Go.

(cherry picked from commit 05bc5e36ff)
2020-08-16 07:19:20 -07:00
lhchavez 686500ef90 Merge pull request #429 from josharian/cherrypick-commit
cherrypick: wrap git_cherrypick_commit
(cherry picked from commit 45097a857c)
2020-08-16 07:19:20 -07:00
lhchavez d84378238a Merge pull request #423 from josharian/more-annotated-commit
merge: add two missing AnnotatedCommit methods
(cherry picked from commit 21d618136f)
2020-08-16 07:19:20 -07:00
lhchavez e43846bffd Merge pull request #400 from ramanenka/git_index_add_frombuffer
Add binding for `git_index_add_frombuffer`

(cherry picked from commit 06764f48dc)
2020-08-16 07:19:20 -07:00
Richard Burke bd2a0c830e Remove Version from RevertOptions
Version is defaulted to GIT_REVERT_OPTIONS_VERSION

(cherry picked from commit 4bca045e5a)
2020-08-16 07:19:20 -07:00
Richard Burke b55ee91e3c Add revert functionality
Closes #436

(cherry picked from commit 30c3d0ffe2)
2020-08-16 07:19:20 -07:00
lhchavez 2fba250690 Free() the copies of repository.LookupXxx()
`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.

(cherry picked from commit 2bb5930733)
2020-08-16 07:19:20 -07:00
lhchavez d47253fb80 Update CI configuration
This change:

* Updates the GitHub actions so that they run different commands for the
  dynamic and static flavors of libgit2.
* Updates the .travis.yml file so that it does roughly the same as the
  GitHub actions.
* Adds the release-* branches to the CI configurations.

(cherry picked from commit 26edffd5f5)
2020-08-16 07:19:20 -07:00
lhchavez 9f2bfe5f32 Merge pull request #520 from libgit2/actions
Setup CI via Actions

(cherry picked from commit f21ecd9e74)
2020-08-16 07:19:20 -07:00
lhchavez 75b56d820b Merge pull request #527 from dbolkensteyn/master
Fixes #513 - Segfault during tree walk

(cherry picked from commit 75c5e41422)
2020-08-16 07:19:20 -07:00