Commit Graph

35 Commits

Author SHA1 Message Date
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 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
Will Medlar a2ac1b9ed1
Fix typo in constant name 2018-12-17 01:56:37 -06:00
Carlos Martín Nieto 58334cf604 First round of mass keep-alive additions 2017-07-08 09:11:38 +02:00
Mirko Nosenzo 6ffad323ba
Removed Useless Argument Check 2016-08-28 11:21:10 +02:00
Mirko Nosenzo 6fa4c8ea15 Checkout Payload Pointer Fix
- Tracking pointer once
- Tracking pointer and not struct
2016-06-25 11:39:44 +02:00
Mirko Nosenzo 18802c24e3 Checkout Callbacks Payload Check in Callback Functions
Checking payloads in callback functions
2016-05-29 15:27:48 +02:00
Mirko Nosenzo db6f44c71c Checkout Callbacks Payload Check
Checking payloads before using them
2016-05-29 15:14:16 +02:00
Mirko Nosenzo 278dc9ac4f Checkout Callbacks
- Added CheckoutNotifyType mapping git_checkout_notify_t
- Added CheckoutOpts.NotifyFlags of type CheckoutNotifyType
- Added CheckoutNotifyCallback mapping git_checkout_notify_cb
- Added CheckoutProgressCallback mapping git_checkout_progress_cb
2016-05-29 13:44:18 +02:00
Jose Alvarez 9397af0854 Expose baseline field in CheckoutOptions 2015-09-18 09:50:59 -04:00
Carlos Martín Nieto 28dee704ca Bring back CheckoutForce
This was mistakenly deleted when the SafeCreate was replaced with
RecreateMissing.
2015-07-10 00:31:32 +02:00
Carlos Martín Nieto 85fde1fcfb Merge remote-tracking branch 'origin/master' into next 2015-06-08 04:07:49 +02:00
Carlos Martín Nieto e021457f27 Merge pull request #180 from arcamael/master
Add possibiliy of checkout on specific path
2015-04-03 14:45:38 +02:00
Geoffrey Ragot c4b8861b34 Add possibiliy of checkout on specific path 2015-03-15 10:14:29 +01: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 c78b4d665e Cherrypick 2015-03-04 15:52:54 -08:00
Mark Probst eec61815fb Fix typos in constants 2015-03-04 15:52:50 -08:00
joseferminj 92a1f92d91 Add TargetDirectory field to Checkout options.
TargetDirectory field indicates a alternative checkout path to workdir.
2015-01-29 15:17:46 +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
CMGS 2f93ce39cc embrace static types 2014-08-28 15:40:21 +08:00
CMGS e5e9636ce0 enhance checkout, add CheckoutTree method 2014-08-27 17:03:21 +08:00
Carlos Martín Nieto 9c72700765 checkout: init_opts -> init_options 2014-05-03 18:56:44 +02:00
Jesse Ezell 50a3c4aa09 update to new merge API 2014-03-26 11:28:48 -07:00
Carlos Martín Nieto 263884a908 CheckoutIndex: allow for index to be nil
Allow for the index to be nil and pass that to the library to use the
repository's index.
2014-03-11 03:30:56 +01:00
Carlos Martín Nieto b09c6d8bbe Move checkout functions options more in line with the library
Afjust Checkout -> CheckoutHead and pass nil if the options structure is
nil so as not to overide the library's decisions.
2014-03-11 03:27:35 +01:00
Carlos Martín Nieto b5b0f3f50e Remove custom checkout opts init function 2014-03-11 03:14:36 +01:00
Carlos Martín Nieto 42fce02197 Adjust to checkout_opts -> checkout_options 2014-03-11 03:09:48 +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 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 00e3df94c7 Camel-case constants
Make the names look more like what you'd expect from Go.
2013-09-12 10:40:57 +02:00
Axel Wagner b27c14b620 Implement rudimentary checkout operations 2013-03-19 23:07:05 +01:00