Commit Graph

55 Commits

Author SHA1 Message Date
lhchavez 922f2f7487
Add support for Odb.MultiPackIndex() (#819)
This change exposes the binding for `git_odb_write_multi_pack_index()`.
2021-09-05 19:03:26 -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 91946a5705 Add odb.NewOdbBackendLoose()
This change adds support for odb.NewOdbBackendLoose(). This, together
with the git.Packbuilder, can do what Mempack does with a lot less
memory.
2020-02-23 13:20:13 -08:00
lhchavez 05bc5e36ff Add support for indexers and alternate odb packfiles
This allows for implementations of git servers written in Go.
2020-02-23 09:13:47 -08:00
Carlos Martín Nieto 97e6392d3a Adjust to libgit2 changes 2019-12-10 22:15:32 +00:00
lhchavez 5fda6dd901 Uprev vendored libgit2 to v0.28
New version is here!
2019-02-11 03:57:50 +00:00
Carlos Martín Nieto ee6dff2f8e Use git_object_t instead of deprecated git_otype 2019-01-05 10:48:42 +00:00
Carlos Martín Nieto fc1230ba16
Merge pull request #447 from walkenzoy/master
git2go: small fixes to odb module
2019-01-03 16:22:15 +01:00
lhchavez 344dc33fae Return io.EOF on OdbReadStream.Read()
This change makes OdbReadStream.Read() comply with the usual io.Reader
semantics.
2018-12-28 04:35:20 +00:00
Michel Lespinasse bdca40d275 git2go: small fixes to odb module
- Fix couple cgo issues in odb.Write() and odb.Hash(). This is the
  same issue - and same solution - as repo.CreateBlobFromBuffer()
  used to have.

- Add test for odb.Read()
2018-07-03 16:43:07 -07:00
Carlos Martín Nieto cff71166ec Adjust to the change in the git_odb_open_rstream signature 2018-02-22 09:28:58 +01:00
Carlos Martín Nieto 55a1096141 Third round of keep-alive aditions 2017-07-08 16:07:51 +02:00
Carlos Martín Nieto f037074198 Merge remote-tracking branch 'origin/next' 2017-01-20 00:46:34 +00:00
Mark Karpeles b829eb1edb odb & refdb: make New*BackendFromC take unsafe.Pointer as argument allowing argument to be set from different package 2016-09-30 23:00:20 +09:00
Kirill Smelkov cf7553e72c odb: Expose git_odb_object_type() as OdbObject.Type()
It might be needed when one is writing `git cat-file --batch` equivalent
which has output format

    <sha1> SP <type> SP <size> LF
    <contents> LF
2016-07-19 22:48:52 +03:00
Ian Lance Taylor dc8b154f4f odb: don't copy buffer 2016-02-16 21:40:05 -08:00
Ian Lance Taylor b70973e5c7 Merge remote-tracking branch 'upstream/master' 2016-02-16 21:06:45 -08:00
Han-Wen Nienhuys 773ac24a16 Expose git_odb_read_header as Odb.ReadHeader.
This function is much faster for discovering sizes for a given OID.
2016-02-03 15:56:39 +01:00
Ian Lance Taylor 42b11d403d handles, merge, odb: changes for Go 1.6 pointer passing rules
See http://tip.golang.org/cmd/cgo/#hdr-Passing_pointers .
2016-01-07 18:37:46 -08:00
Augie Fackler 714cd56c71 odb: remove debug fmt.Printlns
These appear to be left over debug statements, and they also look like
they were intended to be fmt.Printf calls anyway.
2015-11-02 16:00:19 -05:00
Carlos Martín Nieto 36e0a256fe Update to libgit2 b6011e29 2015-06-08 04:11:21 +02:00
Patrick Steinhardt e919653755 odb: 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 520a0425c7 Add the newer missing thread-locking instances 2014-12-06 03:03:26 +01:00
Carlos Martín Nieto 8c631b0c25 Add missing thread locking 2014-12-06 02:45:26 +01:00
Carlos Martín Nieto 2594f3f889 Odb: use a callback instead of a channel for ForEach
A channel provides no way to specify whether we stopped sending data
because of an error or because there is no more data.

Therefore, make Odb.ForEach() take a callback with which the user is free to
do whatever they need, letting us return en error.
2014-05-06 14:19:34 +02:00
Aidan Nulman fc70808cb7 update for upstream changes 2014-04-03 16:49:22 -04:00
Aidan Nulman d9f4adff6c Merge branch 'master' into custom_odb
Conflicts:
	odb.go
	wrapper.c
2014-04-03 16:41:43 -04:00
Aidan Nulman b5e60dc106 explicit returns 2014-04-03 16:39:21 -04: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
Aidan Nulman 2656a72e82 Merge branch 'master' into custom_odb
Conflicts:
	git.go
	reference.go
	repository.go
	submodule.go
2014-02-24 03:05:44 -05:00
Aidan Nulman 1c23e8ece3 add OdbBackend.Free() and the C it wraps; go fmt odb.go 2014-01-29 18:55:17 -05:00
Aidan Nulman f610cf25d7 Merge branch 'master' into custom_odb 2014-01-28 22:49:55 -05:00
Claudiu-Vlad Ursache bf209ca2ba Remove unnecessary cast. 2014-01-26 12:36:05 +01:00
Claudiu-Vlad Ursache 4ce2eb713b Add Odb hash function. 2014-01-25 22:18:32 +01:00
Aidan Nulman e686586149 remove unnecessary comment 2013-12-20 14:26:00 -05:00
Aidan Nulman 59c7bd5ce4 Add OdbBackend constructor 2013-12-20 14:11:24 -05:00
Aidan Nulman 507a204249 Rename constructor functions to New... 2013-12-19 17:24:44 -05:00
Aidan Nulman 19b241bd55 Refactor InitRepositoryWCustomOdbBackend() into component functions 2013-12-19 00:33:23 -05:00
Aidan Nulman dfe6d1ab7e Stop assuming ODB backend includes wrapping routine; wrap in git2go instead 2013-12-18 17:25:54 -05: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
Vicent Martí da5033fb98 Merge pull request #38 from libgit2/odb-stream
Wrap the odb streams
2013-09-17 08:03:34 -07:00
Carlos Martín Nieto 008e1efb35 Object types are constants
Define the object type values as constants
2013-09-11 23:01:27 +02:00
Carlos Martín Nieto 621397026c Wrap the odb streams
The interface to these streams should be what you expect from Go, and
both have Write and Close functions so they implement
Reader/ReadCloser and Write/WriteCloser respectively.
2013-09-11 19:25:40 +02:00
Vicent Martí 62f65d071d Merge pull request #13 from libgit2/polymorphism-take-2
My take on polymorphism
2013-06-13 10:15:36 -07:00