Commit Graph

45 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 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
michael boulton aeb22bcf7d
Make index time fields public (#750)
From gorelease:
```
Compatible changes:
- IndexTime.Nanoseconds: added
- IndexTime.Seconds: added
```
There are no extra tests because there isn't really anything to test

closes #304
2021-02-15 07:37:55 -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 cf6522c7fe refactor: Rename methods with Get prefix
It is not Go idiomatic to put Get into the getter's name.

https: //golang.org/doc/effective_go.html#Getters
Co-Authored-By: lhchavez <lhchavez@users.noreply.github.com>
2020-05-09 23:32:17 -04:00
lhchavez 00374b39aa Update the method name 2020-02-23 14:38:10 +00:00
lhchavez c20008416a Merge remote-tracking branch 'upstream/master' into git_index_add_frombuffer 2020-02-23 13:53:17 +00:00
Melvin dd973b99ad
Add index.Clear() to clear the index object 2018-10-25 15:52:43 -07:00
Vadzim Ramanenka 79fe156d30 Add binding for `git_index_add_frombuffer` 2017-07-17 17:05:03 +03:00
Carlos Martín Nieto 7d29d68644 Second round of keep-alives 2017-07-08 11:38:19 +02:00
ezwiebel c18c8693fe Implement git_index_remove_directory in index wrapper 2016-10-20 15:49:24 +11:00
Carlos Martín Nieto 6d6736b2bd Merge remote-tracking branch 'upstream/master' into next 2016-02-15 15:02:19 +01:00
FUJII Ryota 20ab28bfea Add Index.Find() and Index.FindPrefix() 2015-12-21 18:19:03 +09:00
FUJII Ryota 1cdf1d70a2 Fix a memory leak in Index.EntryByPath() 2015-12-16 16:43:26 +09:00
FUJII Ryota ae107d5f56 Fix memory leaks in NewIndex() and OpenIndex() 2015-10-27 15:20:50 +09:00
Calin Seciu 367cd8eb9b Update libgit2 to 821131f
The API changes are:

- `*Remote.Connect`

  ```go
  // from:
  func (o *Remote) Connect(direction ConnectDirection, callbacks *RemoteCallbacks) error
  // to:
  func (o *Remote) Connect(direction ConnectDirection, callbacks *RemoteCallbacks, headers []string) error
  ```

- `*Remote.ConnectFetch` - `headers` was added as above
- `*Remote.ConnectPush` - `headers` was added as above
2015-10-26 16:20:18 +02:00
FUJII Ryota b8283e7277 Add EntryByPath method to Index 2015-09-28 20:38:04 +09:00
Carlos Martín Nieto d5890f58e8 Run go fmt
As it seems to be something that many people can't get over, reformat
all the files; as we're breaking things, whoever depended on 'next' will
have to take many changes into account anyway, so let's include this to
reduce the noise of incoming patches.
2015-08-31 20:22:17 +02:00
Carlos Martín Nieto 36e0a256fe Update to libgit2 b6011e29 2015-06-08 04:11:21 +02:00
Patrick Steinhardt d95932c84a handles: panic when we cannot retrieve handle data 2015-05-22 09:02:39 +02:00
Patrick Steinhardt 9bbec34885 index: use HandleList for C function callbacks. 2015-05-22 09:02:24 +02:00
Carlos Martín Nieto 72c19f73c9 Index: Add Path() accessor 2015-05-19 15:05:00 +02:00
Carlos Martín Nieto d7a0495000 Index: Add OpenIndex
This lets you persist an index at an arbitrary location.
2015-05-19 14:56:01 +02:00
Carlos Martín Nieto a8ad0d2040 Index: Add ReadTree() 2015-05-19 14:49:05 +02:00
Mark Probst b3e7304abf Add a FIXME. 2015-03-23 12:02:17 -07:00
Carlos Martín Nieto a9d993f3d1 Remove useless includes 2014-12-11 02:59:07 +01:00
Carlos Martín Nieto 99d10775d6 Merge pull request #125 from lucas-clemente/master
implemented Index.AddAll as git_index_add_all wrapper
2014-10-25 18:11:52 +02:00
Lucas Clemente 9d37f81764 implemented Index.AddAll, Index.RemoveAll, Index.UpdateAll 2014-10-24 21:55:08 +02:00
Ryan Dahl 5539137e9a Use Filemode type in TreeEntry and IndexEntry
Fixes #121
2014-10-20 11:58:55 -04:00
Daniel Kertesz c2f6381252 add Index#RemoveByPath. 2014-09-07 12:45:52 +02:00
Carlos Martín Nieto f953d4e5c7 Index: add functions to handle the data structure
Index is not just the index file
2014-05-25 18:12:50 +02:00
Jesse Ezell b660db0a4b make it possible to handle errors 2014-04-02 10:31:48 -07:00
Jesse Ezell dcdf2c3555 add conflict functions 2014-03-30 19:53:07 -07:00
Jesse Ezell 1f3f8adda8 Add index WriteTreeTo + test 2014-03-20 20:49:05 -07: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 5f4283fac3 Merge branch 'index-entries' 2014-02-26 15:22:53 +01:00
Carlos Martín Nieto 14f902afed Adjust to oid -> id 2014-02-26 15:22:48 +01:00
Carlos Martín Nieto 1e01cae286 Remove pointer to git_index_entry
We have all the data
2014-02-26 15:19:07 +01:00
Tobias Haar 054268a634 added write method 2014-01-24 01:10:23 +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
Axel Wagner 179b69ce21 Support for index-entries 2013-05-22 14:41:42 +02:00
Carlos Martín Nieto 33f4594e9c Wrap git_index 2013-03-06 13:10:53 +01:00