This halves the amount of code we have to take into account for dealing
with the config.
There is a slight change in the API. Config.get_multivar() returns an
iterator instead of a list, which lets us reuse code from the general
iterator and is closer to libgit2's API.
The keyword for linking to a mehtod is 'meth', not 'method'. Setting the
'currentmodule' allows us to link without the 'pygit2' prefix in the
link text.
The C API expects a non-NULL new name and raises an assertion if we
don't protect against such input, so let's guard against falsy values,
which also takes care of the empty string, which is also not valid
input.
Casting a pointer to a non-pointer type is something which you should
never do. Instead, do something a bit more convoluted, but which is
guaranteed to give us the right pointer, as well as making sure that the
memory we exchange between python/cffi and the C extension is of the
right pointer size.
While we're touching this code, fix which object we pass to the Remote
constructor to keep alive. We need to pass the Repository object to
stop it from becoming unreferenced (and thus freeing memory the remote
needs) instead of the git_repository pointer.
The documentation recommends adding the ffi code as an extension so it
gets built at the right time.
Make use of the LIBGIT2 environment variable to build and link the ffi
module the same way the C extension does so the user doesn't have to
export CFLAGS.
Pass the contents of the buffer containing the git_oid to bytes() so
build a raw representation of its contents. Using bytes(ffi.buffer(...))
returns the representation of the buffer.
Passing a tuple to the mapping interface isn't the best of interfaces,
as the key is only the string.
Instead, expose `Config.get_bool()` and `Config.get_int()` methods to
parse the values as per the git-config rules before returning the
appropriate type to the user.
The mapping interface itself returns a string.
This moves enough code into python with CFFI to pass the test_remotes
unit tests. There is no credentials support yet.
There is a small change in the return value of Remote.fetch() in that we
now return a TransferProgress object instead of extracting a few values
into a dictionary.
There is no more MergeResult type. Instead, the user can use
Repository.merge_analysis() to get an overview of their options and call
git_merge() when they mean to merge.
The git_merge() function now also performs a checkout.
The type of a config value depends on the tool that interprets
it. Parsing eagerly can lead to a situation where we return a bool
instead of a string or a number.
Let the user specify the type themselves by passing in a (str, type)
tuple into the mapping interface.
This patch is mostly about making sure that we free the copies of what
we have, as well as making sure that we can free it.
The IndexEntry forgot to free its path, but it also used a pointer to
python-owned memory, which could be freed at any time.
MergeResult completely lacked a deallocator.
Signature needs to make sure we can free the enocoding, and not to set
an owner when we own the memory (in this case for the default
signature).
The repository needs to get rid of its reference to the object list when
returning.
The transfer progress callback needs to decref the stats object.
When a class is a base type, it must use its type's tp_free function to
trigger the real free, instead of PyObjec_Del().
We do not always follow this convention, so let's give it a once-over
and make sure we do that or that it's not a base type. Many of the types
have the flag set in the struct, but do not pass the allocator function
at init time, which makes them not really be a base. Remove the flag for
those types.
The docs say to use tp_free() to free the memory, and even though we use
PyObject_Del() everywhere else, using this in the credentials does cause
issues.
It claims you need to checkout a branch after clone, which is not the
case currently (the clone function will do it for you).
While here, format the docstring for sphinx to make it pretty.