Commit Graph

972 Commits

Author SHA1 Message Date
Calin ea645bc456 Set BasicAuth in http.go only if username and password are not empty (#914)
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)
2022-07-13 11:50:49 +00:00
github-actions[bot] ea4c8f5916
Add refspec bindings (#898) (#909)
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>
2022-02-24 19:29:44 -08:00
github-actions[bot] 1d03712afd
rebase: Add wrapper for `git_rebase_inmemory_index()` (#900) (#905)
* 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>
2022-02-24 19:18:54 -08:00
Dylan Richardson 4941b3d1cb
readme: link to godoc for current main branch (#894)
This is a release-specific change corresponding to #886
2022-01-22 19:03:53 -08:00
github-actions[bot] de2552a523
Add ProxyOptions for push operations (#872) (#881)
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>
2022-01-17 19:04:57 -08:00
github-actions[bot] 71def521d3
Add EnableFsyncGitDir to enable synchronized writes to the gitdir (#874) (#879)
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>
2022-01-17 19:02:00 -08:00
lhchavez 0c7782a2f6
Generate stringer files automatically (#841) (#866)
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>
2021-11-09 06:48:31 -08:00
lhchavez 1828c9db5e
Fix replace statement example in README.md (#859) (#862)
(cherry picked from commit 533c82f270)

Co-authored-by: Ignacio Taranto <ignacio_taranto@protonmail.com>
2021-11-09 06:36:10 -08:00
github-actions[bot] a4d6699c91
Make ssh commands used in the git smart transport compatible with libgit2 (#852) (#855)
* 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>
2021-11-09 06:27:06 -08:00
github-actions[bot] 34d31c0438
bugfix: HTTPS Clone fails with remote pointer not found using Go transport (#836) (#842) (#847)
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>
2021-11-09 06:22:32 -08:00
lhchavez 7145746145
Declare forward-compatibility with libgit2 v1.3.0 #minor (#845)
This commit marks this (Golang) version of git2go as being compatible
with libgit2 v1.3.0.
2021-10-16 04:57:15 -07:00
github-actions[bot] c26c144a82
Allow building libgit2 with Chromium zlib (#831) (#832)
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>
2021-09-06 05:26:01 -07:00
github-actions[bot] 4a1a8951e0
Add support for managed SSH transport #minor (#814) (#815)
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>
2021-09-05 17:07:52 -07:00
github-actions[bot] 7b11c62bc1
Add support for managed HTTP/S transports (#810) (#811)
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>
2021-09-05 16:41:53 -07:00
github-actions[bot] 781e820fca
Add support for custom smart transports (#806) (#807)
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>
2021-09-05 16:00:10 -07:00
github-actions[bot] bb7920d61f
Make all non-user-creatable structures non-comparable (#802) (#803)
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>
2021-09-05 14:00:24 -07:00
lhchavez 5bc02752df
Declare forward-compatibility with libgit2 v1.2.0 #minor (#800) (#801)
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)
2021-09-04 20:12:48 -07:00
github-actions[bot] 6ee9afef19
Prepare for the v1.2.0 release (#796) (#797)
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>
2021-09-04 14:21:20 -07:00
github-actions[bot] d410e7ecf7
Add DiffIgnoreWitespaceEol and deprecate DiffIgnoreWitespaceEol (#774) (#793)
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>
2021-09-04 13:56:35 -07:00
github-actions[bot] a2a0858e3a
Add `CreateCommitWithSignature` (#782) (#792)
This change adds the wrapper for `git_commit_create_with_signature`.

(cherry picked from commit 15434610fe)

Co-authored-by: lhchavez <lhchavez@lhchavez.com>
2021-09-04 13:51:44 -07:00
lhchavez a47c12d858
Rename the default branch to `main` (#786) (#787)
We've renamed the default branch from `master` to `main`, so we need to
change a bunch of references to that.

(cherry picked from commit be5a99a807)
2021-09-04 13:41:41 -07:00
lhchavez dbb9b3b5d0
Add `Repository.CreateCommitBuffer` (#781) (#783)
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)
2021-09-04 13:28:05 -07:00
lhchavez a7c2176e8d
Remove the legacy builders (#776) (#778)
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)
2021-09-04 12:52:37 -07:00
github-actions[bot] 103e835387
add wrapper for git_config_open_default (#758) (#766)
(cherry picked from commit 1e2cb92b48)

Co-authored-by: Vladimir Buzuev <44682889+vladimir-buzuev@users.noreply.github.com>
2021-04-04 08:29:36 -07:00
github-actions[bot] b5bd080841
fix buldled static build on Windows/MinGW (#761) (#762)
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>
2021-04-04 08:28:41 -07:00
github-actions[bot] 3bbde00303
Git repository item path (#757) (#759)
add wrapper for `git_repository_item_path`

(cherry picked from commit a4d202ed7b)

Co-authored-by: Vladimir Buzuev <44682889+vladimir-buzuev@users.noreply.github.com>
2021-04-04 07:56:22 -07:00
github-actions[bot] 0e6a600b79
Make index time fields public (#750) (#753)
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>
2021-02-15 13:58:19 -08:00
github-actions[bot] a8883c8679
fix: Use `err` instead of error as a variable name for errors (#746) (#747)
fix #745

(cherry picked from commit f6c5753df8)

Co-authored-by: Suhaib Mujahid <suhaibmujahid@gmail.com>
2021-02-15 13:57:27 -08:00
github-actions[bot] 9030cade50
Implement git_repository_set_config (#735) (#742)
Closes #732

(cherry picked from commit 2fd0495c43)

Co-authored-by: Byoungchan Lee <daniel.l@hpcnt.com>
2021-02-06 05:42:29 -08:00
github-actions[bot] 5621f1b826
Support git_remote_create_with_opts (#733) (#741)
Closes #645

(cherry picked from commit 73d97b9bbe)

Co-authored-by: Byoungchan Lee <daniel.l@hpcnt.com>
2021-02-05 20:06:14 -08:00
github-actions[bot] 71aa7350af
Support git_repository_message, git_repository_message_remove (#734) (#738)
Closes #646

(cherry picked from commit 07147a8ea8)

Co-authored-by: Byoungchan Lee <thisisbclee@gmail.com>
2021-02-03 05:33:25 -08:00
github-actions[bot] 5cfb6c2b85
Rename the build files (#724) (#726)
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: #711
Fixes: #617
(cherry picked from commit 4b2ac7c998)

Co-authored-by: lhchavez <lhchavez@lhchavez.com>
2020-12-13 15:47:34 -08:00
github-actions[bot] 9b6e1d92cc
Support more MergeBase functions (#720) (#722)
This change adds support for MergeBaseMany, MergeBasesMany, and
MergeBaseOctopus.

(cherry picked from commit 698ddfb4ac)

Co-authored-by: lhchavez <lhchavez@lhchavez.com>
2020-12-13 11:09:28 -08:00
github-actions[bot] d21ba51f4e
More callback refactoring (#713) (#717)
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>
2020-12-10 18:01:41 -08:00
github-actions[bot] 3128d76936
Ensure that no pointer handles leak during the test (#712) (#714)
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>
2020-12-10 06:38:14 -08:00
lhchavez e57ff6c391 Add `NewCredentialSSHKeyFromSigner` (#706)
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)
2020-12-06 12:39:08 -08:00
lhchavez 07b98b44c3 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 12:39:08 -08:00
github-actions[bot] b7d6ab837c
Refactor all callbacks (#700) (#703)
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>
2020-12-05 16:23:04 -08:00
github-actions[bot] a54915d90b
Mark some symbols to be deprecated #minor (#698) (#699)
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:43:02 -08:00
nmeum 30caea3934
Relax libgit2 minor version check (#696) (#697)
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)
2020-11-29 16:33:37 -08:00
github-actions[bot] 46766a72f0
Expose GIT_CERT_SSH_SHA256 (#690) (#694)
Newer versions of libssh2 use SHA256 fingerprints

(cherry picked from commit 7497529f70)

Co-authored-by: Hans Duedal <hans.duedal@gmail.com>
2020-11-26 21:03:12 -08:00
github-actions[bot] 4f57b9bff6
Add ReferenceNormalizeName (#681) (#686)
(cherry picked from commit 2bd574b6bd)

Co-authored-by: Segev Finer <segev@codeocean.com>
2020-11-13 18:36:03 -08:00
github-actions[bot] c53a41ce8e
Travis-ci: added support for ppc64le (#682) (#683)
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 06:21:55 -08:00
github-actions[bot] 2bf0e14e9e
Add GIT_BLAME_USE_MAILMAP flag (#676) (#678)
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:04:23 -08:00
lhchavez bcfa256837
feat: Implement an option to control hash verification (#671) (#675)
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 19:15:03 -08:00
lhchavez f83530b18d
CI refresh (#666)
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.
2020-10-23 05:47:14 -07:00
Sami Hiltunen 10d5ebf231
apply: Add bindings for git_apply_to_tree (#657)
Adds bindings to the git_apply_to_tree function that allows applying
a diff directly to a tree.
2020-10-23 05:17:38 -07:00
lhchavez 3a4204bd93
Make `TestApplyDiffAddFile()` explicitly `.Free()` stuff (#661)
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!
2020-10-22 06:30:31 -07:00
Suhaib Mujahid 5b6ce70b89
refactor: Use undeprecated options init (#656)
This PR move form linking against the deprecated `init_options` functions to the renamed `options_init` functions.

For more context see libgit2/libgit2@0b5ba0d744 and libgit2/libgit2@c6184f0c4b.
2020-10-22 06:18:11 -07:00
Patrick Steinhardt 37b81b61f1
repository: Implement wrappers for `git_object_lookup_prefix` (#658)
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.
2020-10-22 05:21:25 -07:00