Commit Graph

19 Commits

Author SHA1 Message Date
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
lhchavez 8d27336e8a Add support for Packbuilder.InsertFromWalk()
This change adds support for Packbuilder.InsertFromWalk() from libgit2.
2018-11-15 03:20:51 +00:00
Carlos Martín Nieto 55a1096141 Third round of keep-alive aditions 2017-07-08 16:07:51 +02:00
Patrick Steinhardt a843b7247f packbuilder: use HandleList for C function callbacks. 2015-05-22 09:02:24 +02:00
Mark Probst 45d88ca5f4 go fmt 2015-03-04 15:52:59 -08:00
Carlos Martín Nieto a9d993f3d1 Remove useless includes 2014-12-11 02:59:07 +01:00
Carlos Martín Nieto 8c631b0c25 Add missing thread locking 2014-12-06 02:45:26 +01:00
Carlos Martín Nieto 7e3c361ac4 Packbuilder: use a callback for ForEach instead of a channel
Channels provide no means to report an error. Closing a channel could
mean anything.

This is particularly important when dealing with IO, which we do quite
often in the pack builder. Use ForEach which returns an error instead.
2014-05-06 14:43:38 +02: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 b5b891a03d Packbuilder: adjust to changes in dev 2013-11-13 06:53:10 +01:00
Carlos Martín Nieto a33875f9c5 Packbuilder: compilation fixes
Don't name the return values, as they conflict with the names we want
inside and the types don't match what we want to have inside. We need
them to be two-way channels in the function, and then pass
unidirectional references to the different functions.
2013-06-17 01:55:36 +02:00
Vicent Martí 01d1a5c5d5 Merge pull request #24 from carlosmn/packbuilder-abort
Allow aborting the pack writing operation
2013-06-13 10:15:12 -07:00
Michael Crosby 6513377da0 Add nil for optional parameters for pack_write
The git_packbuilder_write function now takes
two optional arguments used for information
callbacks.  These are currently not needed
in the Go wrapper.
2013-06-07 19:08:10 -04:00
Carlos Martín Nieto b189d7919a Allow aborting the pack writing operation
In case of an error in the writer, the packbuilder will stay around
waiting for someone to read from its channel. The state associated
with a packbuilder is non-trivial and it will keep a reference to the
object, so the GC won't be able to free it.

Change the ForEach interface to also return a "stop" channel. Closing
the channel or writing into it will cause the first receive clause to
act, making the callback to return -1, aborting the operation and
ending the goroutine, freeing its hold on the packbuilder.
2013-05-23 11:44:06 +02:00
Axel Wagner 3a1bbbdf9d Correct some errors from 1da989e 2013-05-16 16:53:21 +02:00
Axel Wagner 1da989e28b Add Write(w io.Writer) to packbuilder
This wraps (*packbuilder).ForEach(), making it possible to write the
pack easiliy to a tcp-connection, a HTTP-Body or the like.
2013-05-16 14:02:22 +02:00
Axel Wagner 140f362428 Add support for git_packbuilder 2013-05-16 13:56:07 +02:00