Commit Graph

38 Commits

Author SHA1 Message Date
lhchavez b78bde3d74 Make all Options objects consistent
This change makes all Options objects have child Option fields as values
(instead of pointers) to mirror the libgit2 interface. It also names
them Options instead of Opts to match the current libgit2 nomenclature
and removes the Version fields.
2021-09-05 18:52:01 -07:00
lhchavez 5def02a589 The big Callback type adjustment of 2020
This change makes all callbacks that can fail return an `error`. This
makes things a lot more idiomatic.
2021-09-05 18:52:01 -07:00
lhchavez dbe032c347
Make all non-user-creatable structures non-comparable (#802)
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.
2021-09-05 13:59:36 -07:00
lhchavez 10c67474a8
More callback refactoring (#713)
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.
2020-12-10 07:19:41 -08:00
lhchavez 5d8eaf7e65
Refactor all callbacks (#700)
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`.
2020-12-05 13:13:59 -08:00
lhchavez 137c05e802
Mark some symbols to be deprecated #minor (#698)
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
2020-12-05 07:23:44 -08: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
Mikołaj Baranowski a395d3f635 clone_checkout_strategy removed
https://github.com/libgit2/libgit2/releases/tag/v0.26.0
2017-09-03 16:51:11 +02:00
Carlos Martín Nieto 55a1096141 Third round of keep-alive aditions 2017-07-08 16:07:51 +02:00
Carlos Martín Nieto 47191d1274 Submodule: use the Repository constructor 2015-06-30 19:12:39 +02:00
Carlos Martín Nieto d2808d1610 Create a SubmoduleCollection for managing submodules
Similarly to RemoteCollection, this allows us to namespace the submodule
operations much more concisely and removes API on the Repository.
2015-06-28 00:58:31 +02:00
Carlos Martín Nieto ba0a24087a Get rid of Owner() on Remote and Submdoule
These are inherently unsafe. The underlying pointer might get released
at any moment.
2015-06-28 00:49:56 +02:00
Carlos Martín Nieto d400f1d5b2 Update to libgit2 fa39975 2015-06-28 00:34:54 +02:00
Carlos Martín Nieto 36e0a256fe Update to libgit2 b6011e29 2015-06-08 04:11:21 +02:00
Carlos Martín Nieto 85fde1fcfb Merge remote-tracking branch 'origin/master' into next 2015-06-08 04:07:49 +02:00
Patrick Steinhardt d95932c84a handles: panic when we cannot retrieve handle data 2015-05-22 09:02:39 +02:00
Patrick Steinhardt de45a4b8ed submodule: use HandleList for C function callbacks 2015-05-22 09:02:24 +02:00
Carlos Martín Nieto c4fce1a218 Update to libgit2 d675982a153
There's been some changes to the checkout strategy, especially the
SAFE_CREATE mode, which is now the RECREATE_MISSING flag, though that
shouldn't be necessary to use in the general case.

The largest changes come from the removal of the signture from
ref-modifying functions/methods and the removal of the reflog string in
all but those directly related to moving references.
2015-03-15 01:49:32 +01:00
Mark Probst e439b931a6 Default signature 2015-03-04 15:52:57 -08:00
Patrick Steinhardt 2e481dbc79 Fix ForeachSubmodule panicing.
As the SubmoduleVisitor function is called from inside libgit2 we
cannot use Go types in its signature. Fix by using C types
instead.
2015-01-28 15:07:32 +01:00
David Calavera ea7f567756 Remove version from opts structure.
It's not necessary.
2015-01-08 15:06:35 -08:00
David Calavera 22f4a4edaa Do not double check if the signature is nil. 2015-01-08 14:21:29 -08:00
David Calavera 9b914e07cc Add Submodule.Update method.
Update libgit2 to a version that includes https://github.com/libgit2/libgit2/pull/2804.
2015-01-08 13:44:58 -08:00
David Calavera 8adbc08d70 Fix inconsistent function call in Submodule. 2015-01-06 14:02:44 -08:00
Carlos Martín Nieto a9d993f3d1 Remove useless includes 2014-12-11 02:59:07 +01:00
Carlos Martín Nieto 668aa5dae1 Make the constants have types
While Go will assign the correct type to a const block when it
auto-creates the values, assigning makes the const be typeless and will
only gain it in each particular use.

Make each constant in the blocks have an assigned type.
2014-10-28 11:29:31 +01:00
Simon Menke 429408dbe5 Added force argument for (*Submodule).Reload() and (*Repository).ReloadAllSubmodules() 2014-03-27 11:32:22 +01:00
Jesse Ezell e2db9b16cd merge latest, cleanup error handling, add thread locks 2014-02-26 10:41:20 -08:00
Carlos Martín Nieto 00ea11691b Convert the rest of the errors 2014-02-26 16:14:31 +01:00
Jesper Hansen 499f52a354 Added git error code to the error object. 2014-02-26 16:10:00 +01:00
Carlos Martín Nieto c6d1bde37c Return SubmoduleRecurse 2014-02-23 16:08:19 +01:00
Carlos Martín Nieto 1b09b03c0e Merge commit 'refs/pull/53/head' of github.com:libgit2/git2go
On top: fix git_buf handling and rename signature

This fixes #57, #54.

Conflicts:
	git.go
	reference.go
	repository.go
	submodule.go
2014-02-23 15:31:22 +01:00
Aidan Nulman f66502aaf4 update git2go to support latest libgit2 development commit (id: 66af84) 2014-01-29 18:01:26 -05:00
Jason Toffaletti 313e1126dd add git_submodule_recurse_t type 2014-01-02 23:33:08 +00:00
Carlos Martín Nieto a40bdfd420 Lock the OS thread when acessing errors
The library stores error information in thread-local storage, which
means we need to make sure that the Go runtime doesn't switch OS
threads between the time we call a function and th time we attempt to
retrieve the error information.
2013-12-18 16:18:32 +01:00
Carlos Martín Nieto a5ad8de506 Don't repeat the pkg-config line
This is only needed once per package. Having it on every file makes the
build system ask about it n times, which is silly.
2013-11-14 00:23:04 +01:00
Carlos Martín Nieto 22f43840aa Submodule: adjust to the Default -> Reset change in the library 2013-07-22 01:28:04 +02:00
Vicent Marti 439f7acf28 Submodule wrapping courtesy of @sbinet 2013-03-05 21:05:55 +01:00