It might seem like a really obvious point to make but without
emphasizing it, it isn't completely clear. I would like to mention this
in the Branch section as well for how to point a branch at another
commit but I can't see how to smoothly slide it in.
LIBGIT2_VERSION was previously recorded as LIBGIT2_VER_VERSION which is
incorrect.
We also add basic explanations to all the constants so that the page is
a little less bare. Perhaps this should be done as autodoc style
comments in the code but I guess not.
Renaming a remote in pygit2 has been done via Remote.name= up to now,
but this is inherently unsafe, as it provides no way to pass up the
refspecs that libgit2 was unable to remap.
In fact, if there ever was such problem, we would have segfaulted.
libgit2 now provides a much more direct way of getting back the results,
so expose it as the return value of Remote.rename(). This also removes
the hint that a rename might be something that happens only to the
in-memory structure.
An index may not have an associated repository, so giving it an id in
that case is useless. Raise an error in that case and accept a Tree
object to make the function useful then.
Reconcile the changes between the ffi changes upstream with the changes
to libgit2 in the dev branch.
Conflicts:
src/config.c
src/options.c
src/refspec.c
src/remote.c
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.