This prevents error "read/write on closed pipe".
Go's http.client::send() always closes req.Body, so if the first request attempt
is unsuccessful, any subsequent requests after calling the `CredentialsCallback`
will attempt to read/write on a closed pipe.
(cherry picked from commit 9db5de109c)
This add support for the parse, access, and transform functions for
refspec objects.
(cherry picked from commit eae00773cc)
Co-authored-by: William Bain <bain.william.a@gmail.com>
* rebase: Fix missing initialization of the repo pointer
While the `Rebase` structure has a pointer to the repository the rebase
is creatde in, this pointer isn't ever initialized. Fix this.
* rebase: Add wrapper for `git_rebase_inmemory_index()`
Add a new wrapper for `git_rebase_inmemory_index()`, which can be used
to retrieve the index for an in-memory rebase.
Co-authored-by: Patrick Steinhardt <psteinhardt@gitlab.com>
(cherry picked from commit e7d1b2b69f)
Co-authored-by: Patrick Steinhardt <ps@pks.im>
Analog to #623 but for push operations rather than fetch.
(cherry picked from commit 5eca48cda9)
Co-authored-by: Aurélien <6292584+au2001@users.noreply.github.com>
This adds support for the GIT_OPT_ENABLE_FSYNC_GITDIR option in libgit2.
Co-authored-by: James Fargher <jfargher@gitlab.com>
(cherry picked from commit 1fcc9d8743)
Co-authored-by: James Fargher <proglottis@gmail.com>
Added `stringer` annotations to `git.go` for `ErrorClass` and
`ErrorCode`. Added `generate` rule for `Makefile` to generate
string representations for these types (first building cgo files
in `_obj` dir to get C constants). Finally, updated `ci` actions
workflow to check that generated files are up to date.
Fixes: #543
(cherry picked from commit 5e35338d58)
Co-authored-by: Kirill <g4s8.public@gmail.com>
* Fix ssh commands used in go SmartSubtransport
Before the fix, the commands sent were of the form:
```
git-upload-pack "/bar/test-reponame"
```
This resulted in the git server returning error:
`error parsing command: invalid git command`
This change replaces the double quotes with single quotes:
```
git-upload-pack '/bar/test-reponame'
```
* Update ssh.go
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
(cherry picked from commit 6cea7a7a59)
Co-authored-by: Sunny <darkowlzz@protonmail.com>
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
Fixes: #836
Changes:
* adding a weak bool param for Remote
* create a new remote in the smartTransportCallback incase one is not found
(cherry picked from commit 0e8009f00a)
Co-authored-by: Yashodhan Ghadge <codexetreme@users.noreply.github.com>
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change allows the caller to set the `USE_CHROMIUM_ZLIB=ON`
environment variable to use the Chromium implementation of zlib when
building libgit2.
(cherry picked from commit c6da3b97a8)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change drops the (hard) dependency on libssh2 and instead uses Go's
implementation of SSH when libgit2 is not built with it.
(cherry picked from commit 70e5e419cf)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change uses the newly-exposed Transport interface to use Go's
implementation of http.Client instead of httpclient via libgit2.
(cherry picked from commit b983e1daeb)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change adds support for git smart transports. This will be then
used to implement http, https, and ssh transports that don't rely on the
libgit2 library.
(cherry picked from commit f1fa96c7b7)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change makes all non-user-creatable structures non-comparable. This
makes it easier to add changes later that don't introduce breaking
changes from the go compatibility guarantees perspective.
This, of course, implies that this change _is_ a breaking change, but since
these structures are not intended to be created by users (or de-referenced),
it should be okay.
(cherry picked from commit dbe032c347)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
We can't yet ship a fully libgit2 v1.2.0-compatible library due to a
missing public symbol, but we can allow the v1.1.0-era codebase to link
against libgit2 v1.2.0 in the meantime.
(cherry picked from commit 549706bb57)
This change adds a few more deprecation messages just before we remove
them.
(cherry picked from commit 2077003fa5)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
DiffIgnoreWitespaceEol contains a typo and does not have the same name as it's libgit2 counterpart.
Fixes#773
(cherry picked from commit d4524761d9)
Co-authored-by: Gustav Westling <gustav@westling.dev>
This change adds the wrapper for `git_commit_create_with_signature`.
(cherry picked from commit 15434610fe)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This commit adds the Go binding for `git_commit_create_buffer`. This
will be used to support the 1.2.0 commit create callback.
(cherry picked from commit fbaf9d1d1a)
These builds are no longer working because some of the dependencies now
require newer versions of Go. Seems like the ecosystem has moved to Go
1.11+, so we are now forced to follow suit.
(cherry picked from commit df7084d36a)
seems like need more libraries in LDFLAGS:
* ws2_32 for socket, connect, htonl, etc
* ole32 for CoInitializeEx
* rpcrt4 for UuidCreate
* crypt32 for CertFreeCertificateContext
(cherry picked from commit 0d7c8dadb4)
Co-authored-by: Vladimir Buzuev <44682889+vladimir-buzuev@users.noreply.github.com>
add wrapper for `git_repository_item_path`
(cherry picked from commit a4d202ed7b)
Co-authored-by: Vladimir Buzuev <44682889+vladimir-buzuev@users.noreply.github.com>
From gorelease:
```
Compatible changes:
- IndexTime.Nanoseconds: added
- IndexTime.Seconds: added
```
There are no extra tests because there isn't really anything to test
closes#304
(cherry picked from commit aeb22bcf7d)
Co-authored-by: michael boulton <61595820+mbfr@users.noreply.github.com>
This change renames the build files so they come lexicographically
before any source files. This makes the compile errors (due to
mismatched libgit2 versions) easier to understand, since the
`Build_*.go` files will be tried before the rest, and the `#error` in
those files will kick in, leading to a much better experience.
This unfortunately goes a bit against the defacto standard of using only
lowercase characters in filenames, but the better developer experience
(and better self-diagnosis when things go wrong instead of having to
open a new issue) is worth the deviation.
Fixes: #711Fixes: #617
(cherry picked from commit 4b2ac7c998)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change adds support for MergeBaseMany, MergeBasesMany, and
MergeBaseOctopus.
(cherry picked from commit 698ddfb4ac)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change:
* Gets rid of the `.toC()` functions for Options objects, since they
were redundant with the `populateXxxOptions()`.
* Adds support for `errorTarget` to the `RemoteOptions`, since they are
used in the same stack for some functions (like `Fetch()`). Now for
those cases, the error returned by the callback will be preserved
as-is.
(cherry picked from commit 10c67474a8)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change makes sure that pointer handles are correctly cleaned up
during tests.
(cherry picked from commit e28cce87c7)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
This change adds `NewCredentialSSHKeyFromSigner`, which allows idiomatic
use of SSH keys from Go. This also lets us spin off an SSH server in the
tests.
(cherry picked from commit abf02bc7d7)
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)
Co-authored-by: lhchavez <lhchavez@lhchavez.com>
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)
The major version must still be an exact match since libgit2 uses
semantic versioning and changes to the major number indicate backwards
incompatible changes to the API.
Fixes: #695
(cherry picked from commit 1fabe95fb7)
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>
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>
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>
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.
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!
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.