Commit Graph

848 Commits

Author SHA1 Message Date
lhchavez 9912ed9742
Revert "More diff functionality (#629) (#636)" (#639)
This reverts commit 4d69027787.

v0.27 does not support this API.
2020-08-18 06:52:38 -07:00
github-actions[bot] 4d69027787
More diff functionality (#629) (#636)
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:21:19 -07:00
github-actions[bot] 0430fd700c
Add two more GitHub Actions workflows (#633) (#635)
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:35 -07:00
lhchavez 6453cf9f8a 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:09 -07:00
michael boulton ff0fed0c32 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:09 -07:00
Yuichi Watanabe 7a89ced8fc 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:09 -07:00
Jesse Hathaway 5c0c2356cc 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:09 -07:00
lhchavez 26287a926a 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:09 -07:00
lhchavez 14e29a3390 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:09 -07:00
lhchavez 2635b45d90 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:09 -07:00
lhchavez 1233fdebf5 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:09 -07:00
Takuji Shimokawa aea6cff7ac 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:09 -07:00
Jesse Hathaway 250a674787 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:09 -07:00
lhchavez d6ab8729d8 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:09 -07:00
lhchavez 8334650b1c expose options related to caching
(cherry picked from commit 8b51d0db8e)
2020-08-16 07:19:09 -07:00
Suhaib Mujahid 8e87fa7d72 Check nil signature
(cherry picked from commit 91d08450b6)
2020-08-16 07:19:09 -07:00
lhchavez 447d43c57d 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:09 -07:00
Suhaib Mujahid 0dfadb0dd0 Update README.md
(cherry picked from commit 3a2102638d)
2020-08-16 07:19:09 -07:00
lhchavez 59a177dd02 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:09 -07:00
lhchavez 891d857c3a 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:09 -07:00
lhchavez 231f89164b 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:09 -07:00
lhchavez 26397cdaea 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:09 -07:00
lhchavez 395b2a90a4 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:09 -07:00
lhchavez 5acb58e83d 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:09 -07:00
lhchavez 36b0f8ba75 Merge pull request #429 from josharian/cherrypick-commit
cherrypick: wrap git_cherrypick_commit
(cherry picked from commit 45097a857c)
2020-08-16 07:19:09 -07:00
lhchavez 75daa3227d 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:09 -07:00
lhchavez 23e13acf73 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:09 -07:00
Richard Burke 5acdcfaf86 Remove Version from RevertOptions
Version is defaulted to GIT_REVERT_OPTIONS_VERSION

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

(cherry picked from commit 30c3d0ffe2)
2020-08-16 07:19:09 -07:00
lhchavez 37230d2697 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:09 -07:00
lhchavez b6aa16143b 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:09 -07:00
lhchavez 15641667bd Merge pull request #520 from libgit2/actions
Setup CI via Actions

(cherry picked from commit f21ecd9e74)
2020-08-16 07:19:09 -07:00
lhchavez 5bfa93a8dd Merge pull request #523 from josharian/diff-stringers
make Delta and DiffLineType stringers

(cherry picked from commit 11506ab070)
2020-08-16 07:19:09 -07:00
lhchavez 2ce0cec363 Merge pull request #524 from josharian/doc-params
provide param names in DiffForEachFileCallback

(cherry picked from commit 917d8dcb9e)
2020-08-16 07:19:09 -07:00
lhchavez 61fdd76c76 Merge pull request #503 from jonEbird/static-build-script-cleanup
script/build-libgit2-static.sh: correctly set ROOT

(cherry picked from commit aa802a90db)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto e888805c2b Merge pull request #506 from takuji/git_commit_message_encoding
Add git_commit_message_encoding support

(cherry picked from commit b2e2b2f71b)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto bee1068871 Merge pull request #512 from codeocean/diff-to-buf
Add Diff.ToBuf wrapping git_diff_to_buf

(cherry picked from commit 4fa9349942)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto 544af2b39a Merge pull request #448 ftrom lhchavez/mempack
Add support for mempack

(cherry picked from commit 2f91268f74)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto c1c2b5a730 Merge pull request #466 from lhchavez/repository-create_commit_from_ids
Add support for CreateCommitFromIds

(cherry picked from commit 8766f9f36c)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto 9fd0d987ae Merge pull request #477 from lhchavez/patch-1
Add support for Go 1.11 modules

(cherry picked from commit 2609f4c6f2)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto a13d27e9c0 Merge pull request #475 from lhchavez/self-contained-build
Improve the static build script

(cherry picked from commit b30b050c9c)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto fedb5b8e68 Merge pull request #476 from lhchavez/clean-up-leaked-dir
Clean up one leaked temporary directory

(cherry picked from commit e93f34cf18)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto 7b1c424572 Merge pull request #420 from josharian/rebase-operation-type-stringer
Add RebaseOperationReword, and make RebaseOperationType a stringer

(cherry picked from commit 7ae106611c)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto a07879739f Merge pull request #445 from rmg/exclusive-pkg-config
static: use pkg-config exclusively when using it
(cherry picked from commit bcf325244c)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto d314b459b8 Merge pull request #465 from lhchavez/packbuilder-insert_from_walk
Add support for Packbuilder.InsertFromWalk()

(cherry picked from commit b51a90c133)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto eb38aaaeee Merge pull request #463 from Nivl/patch-1
Add index.Clear() to clear the index object

(cherry picked from commit c27981c283)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto 97d05a1e4c Merge pull request #432 from josharian/simplify-oid
git: simplify some Oid methods
(cherry picked from commit c740e1d83d)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto 13d16e7ac5 Merge pull request #447 from walkenzoy/master
git2go: small fixes to odb module
(cherry picked from commit fc1230ba16)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto 10ce505588 Merge pull request #425 from josharian/more-merge-file-flags
merge: add missing MergeFileFlag constants
(cherry picked from commit e319b9427f)
2020-08-16 07:19:09 -07:00
Carlos Martín Nieto da10fee49e Merge pull request #424 from josharian/sigdoc
signature: improve Signature.Offset docs
(cherry picked from commit 7197faee79)
2020-08-16 07:19:09 -07:00