Commit Graph

33 Commits

Author SHA1 Message Date
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
Dinesh Bolkensteyn bf289c8b36 Fixes #513 - Segfault during tree walk 2019-11-17 17:21:57 +01:00
Steffen Prohaska fcb86e6f8e
tree: keep tree receiver alive as long as dependent entry is used
Signed-off-by: Steffen Prohaska <prohaska@zib.de>
2018-02-09 11:17:10 +01:00
Carlos Martín Nieto 7f685a6ee6 Add Objecer interface
We do want to be able to accept generic objects in functions. Add this interface
so we can accept that instead of specific object types.
2017-07-08 22:53:50 +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 89fc9e7761 Merge pull request #365 from AaronO/fix/memleak-tree-entrybyname
Fix memleaks in Tree.EntryBy(Name/Path/Index), fixes #313
2017-04-13 21:16:30 +02:00
Aaron O'Mullan ee2a023868 Remove unnecessary C.git_tree_entry_free calls ...
As per the docs, these entries belong to the tree and don’t need to be
freed by the caller:
*
https://libgit2.github.com/libgit2/#HEAD/group/tree/git_tree_entry_bynam
e
2017-02-25 02:13:57 +01:00
Aaron O'Mullan f503d918aa Fix memleaks in Tree.EntryBy(Name/Path/Index), fixes #313 2017-02-24 22:55:14 +01:00
Han-Wen Nienhuys 090dc7ee39 Use Filemode in TreeBuilder.Insert, and add test coverage for some
TreeBuilder methods.
2016-02-17 18:23:52 +01:00
Carlos Martín Nieto b7159b0cd4 Move from an Object interface to a type
An Object should be about representing a libgit2 object rather than
showing which methods it should support.

Change any return of Object to *Object and provide methods to convert
between this and the particular type.
2015-08-04 14:47:10 +02:00
Calin Seciu 64c160f6f2 Find tree entry by id
Add support for 'git_tree_entry_byid'.
2015-07-24 19:52:51 +03:00
Patrick Steinhardt c43afaf9c4 tree: use correct C callback signature 2015-05-22 09:56:21 +02:00
Patrick Steinhardt d95932c84a handles: panic when we cannot retrieve handle data 2015-05-22 09:02:39 +02:00
Patrick Steinhardt be3a626f2e tree: use HandleList for C function callbacks. 2015-05-22 09:02:24 +02:00
David Calavera d69c771453 Update libgit2
Fix calls to C.git_treebuilder_create and C.git_treebuilder_write.
2014-12-18 22:59:08 +00:00
Carlos Martín Nieto a9d993f3d1 Remove useless includes 2014-12-11 02:59:07 +01:00
Ryan Dahl 5539137e9a Use Filemode type in TreeEntry and IndexEntry
Fixes #121
2014-10-20 11:58:55 -04:00
David Calavera 9bec36a0b0 Update clone options to be in sync with libgit2 master.
Remove missing constants.
2014-09-03 18:08:48 -07:00
Carlos Martín Nieto a06f4a030a Adjust to Go tip changes
It does not like breaking aliasing rules, so let's keep a casted pointer
for when libgit2 wants that.
2014-04-01 12:36:44 +02:00
Jesse Ezell 5e163fa2e8 add blob chunk creation, creation of tree builders for specific trees, minor API cleanup 2014-03-07 16:43: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 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 b5aca803db Give each const group a type
This allows us to restrict which constants the compiler will allow
through, and makes the sorting in the documentation better.
2013-09-12 10:46:20 +02:00
Carlos Martín Nieto ef5fc37870 Tree: add EntryByPath
The more powerful version of EntryByName.
2013-09-12 10:16:49 +02:00
Carlos Martín Nieto 3cbfdf37f4 Add Filemode to TreeEntry
This field was missing, so let's add it, and let's add the const
definitions for the modes while we're here.
2013-09-09 14:21:16 +02:00
Axel Wagner 28b5284389 Use ObjectType in TreeEntry 2013-04-26 23:28:32 +02:00
Vicent Marti 2bf17ba2f1 Ok, now with shared base object 2013-04-18 00:54:46 +02:00
Vicent Marti d190d8a6b3 Take 2 on polymorphism 2013-04-16 23:04:35 +02:00
Carlos Martín Nieto c854239784 TreeEntry: use Id instead of Oid
Name it like The Library and the rest of the bindings.
2013-03-08 21:26:19 +01:00
Carlos Martín Nieto d43561fbf7 Free Git objects via finalizers or manually
Provide a manual way of freeing objects, but set finalizers for them
in case the user does not want to worry about memory management, which
would be useful for commits or trees, which sare typically small.

When the objects are freed manually, the finalizer is unset to avoid
double-freeing, mimicking what the go runtime does.
2013-03-06 01:47:53 +01:00
Vicent Marti b1d50b70ea Initial commit 2013-03-05 20:53:04 +01:00