1074 Commits

Author SHA1 Message Date
Daniel Bruce
1fbe52c0f7 Add version check to C code 2014-04-29 12:38:30 +02:00
J. David Ibáñez
9d6b15786f Merge remote-tracking branch 'jun/v0.20.3-vs2008' 2014-04-28 17:03:58 +02:00
Jun Omae
c68de8e2b8 make build options.c with VS2008 compiler 2014-04-28 16:24:49 +09:00
Carlos Martín Nieto
9309329b5a Merge pull request #361 from carlosmn/cffi-config
Config: move to cffi
2014-04-26 16:39:50 +02:00
J. David Ibáñez
17ba85831b Drop official support for Python 2.6 2014-04-23 14:01:09 +02:00
Carlos Martín Nieto
1c76d5667a Blob: implement the memory buffer interface
This allows us to expose access to the blob's data without the need to
copy it into new buffer.
2014-04-23 12:35:17 +02:00
Carlos Martín Nieto
1e13a10949 Config: expose config rules parsing
Expose Config.parse_bool() and Config.parse_int() to parse text
according to git-config rules.
2014-04-21 14:11:41 +02:00
Carlos Martín Nieto
c41c1a1c97 Config: move to cffi
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.
2014-04-21 14:11:41 +02:00
J. David Ibáñez
d8bd6f73ab Merge remote-tracking branch 'kluyver/docstrings-update' 2014-04-19 11:38:21 +02:00
Thomas Kluyver
569d396f0d Use repo.head.target instead of repo.head.get_object().hex 2014-04-18 13:44:25 -07:00
J. David Ibáñez
3cc129dd62 Merge remote-tracking branch 'origin/cffi-remote' 2014-04-18 21:56:00 +02:00
Carlos Martín Nieto
4c4968a2fb Fix config documentation keyword
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.
2014-04-18 12:17:54 +02:00
Carlos Martín Nieto
7ed89b0aab Remote: protect against invalid input on rename
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.
2014-04-17 23:18:31 +02:00
Thomas Kluyver
37c01d79c5 Update some docstrings which had got out of date. 2014-04-17 10:13:26 -07:00
Carlos Martín Nieto
d7d0eb37c3 ffi: style changes
Make to_str() accept None as well as ffi.NULL to return as a negative
value, and grab the version in a more compatible way.
2014-04-16 22:17:20 +02:00
Carlos Martín Nieto
5a20510f8a Safer repository pointer extraction
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.
2014-04-16 22:12:54 +02:00
Carlos Martín Nieto
f3bb8a4556 Fix installation-time cffi compilation
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.
2014-04-16 22:12:52 +02:00
Carlos Martín Nieto
b4bc2b6295 Depend on the cffi package
Let both pip and Travis know what we need.
2014-04-16 22:12:24 +02:00
Carlos Martín Nieto
e56ab370a7 Remote: make sure to take the contents of the id
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.
2014-04-16 22:12:24 +02:00
J. David Ibáñez
d51174d34f Install the "decl.h" file 2014-04-16 22:12:24 +02:00
Carlos Martín Nieto
674546bbb5 Some python3 fixes 2014-04-16 22:12:09 +02:00
J. David Ibáñez
397e8ad07c Merge remote-tracking branch 'carlos/config-parse' 2014-04-15 09:01:03 +02:00
Carlos Martín Nieto
73e9e58fa4 Config: make bool and int parsing explicit via functions
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.
2014-04-14 19:37:44 +02:00
Carlos Martín Nieto
072b038210 Implement clone via CFFI as well
This lets us get rid of the last piece of C for anything related to
remotes and credentials.
2014-04-14 11:42:51 +02:00
Carlos Martín Nieto
db218fae3f Remote: get rid of the C code
This code has been obsoleted by the CFFI-using code. Some credentials
code remains in C due to the clone functionality making use of it.
2014-04-14 11:42:51 +02:00
Carlos Martín Nieto
cf2703998e Remote: add documentation strings
Now that it has the features of the old implementation, let's add
documentation on how to use it.
2014-04-14 11:42:51 +02:00
Carlos Martín Nieto
2d1615dd29 Remote: add support for transfer and update_tips though CFFI 2014-04-14 11:42:51 +02:00
Carlos Martín Nieto
4ef3be18cc Remote: support credentials via CFFI 2014-04-14 11:42:51 +02:00
Carlos Martín Nieto
c76c3f0195 Start implementing remotes with CFFI
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.
2014-04-14 11:42:51 +02:00
J. David Ibáñez
d882af8f52 Get ready to release 0.20.3 v0.20.3 2014-04-02 22:28:18 +02:00
Carlos Martín Nieto
114e300b08 Adjust to options changes
We can now use a git_buf to extract the search path.
2014-04-01 19:56:10 +02:00
Carlos Martín Nieto
55037c23a3 Adjust to the merge changes
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.
2014-04-01 19:48:20 +02:00
Carlos Martín Nieto
a870a59f2a Adjust to option struct naming change 2014-04-01 19:47:48 +02:00
Carlos Martín Nieto
e5f6798f67 Adjust to oid -> id renaming 2014-04-01 19:47:48 +02:00
Carlos Martín Nieto
dd6fc972dd Adjust to the git_buf changes
We no longer need the max-path define, so we can get rid of that and the
pypy checking.
2014-04-01 19:47:48 +02:00
Carlos Martín Nieto
9cec62d2e1 Blame: orig_ is now filled 2014-04-01 19:47:48 +02:00
Carlos Martín Nieto
423b912fae Adjust to reference creation signatures 2014-04-01 19:47:48 +02:00
Carlos Martín Nieto
7a606b9b1c Adjust to libgit2 dup changes 2014-04-01 19:47:47 +02:00
J. David Ibáñez
60b4cb537a Writing changelog for v0.20.3 2014-04-01 18:44:39 +02:00
J. David Ibáñez
f0874cc1ea Always use new-style classes in Python 2 2014-03-27 21:00:09 +01:00
J. David Ibáñez
69a96975a9 Merge remote-tracking branch 'carlos/credentials' 2014-03-27 20:54:02 +01:00
Carlos Martín Nieto
687dc5388e config: make type conversion explicit
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.
2014-03-27 18:04:38 +01:00
J. David Ibáñez
607d4810f6 Merge remote-tracking branch 'carlos/leaks' 2014-03-27 13:43:36 +01:00
Carlos Martín Nieto
b37d1c9c1f Plug memory leaks
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.
2014-03-27 13:03:42 +01:00
Carlos Martín Nieto
940a6da929 Make dealloc use tp_free or don't allow inheritance
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.
2014-03-27 09:55:11 +01:00
Carlos Martín Nieto
82d88191bb credentials: use more ducks
Instead of making everyone inherit from our credential types, use an
interface with two attributes, which makes the C code much shorter and
simpler.
2014-03-26 20:23:04 +01:00
Carlos Martín Nieto
77acb11cd0 credentials: memory safety
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.
2014-03-26 19:14:57 +01:00
J. David Ibáñez
e4d45118e6 Merge remote-tracking branch 'carlos/uninitialsed' 2014-03-26 17:52:08 +01:00
Carlos Martín Nieto
b3ce1b5da6 Add credentials support to clone_repository() 2014-03-26 14:50:25 +01:00
Carlos Martín Nieto
75f9f88335 Update clone_repository's docs
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.
2014-03-26 14:48:34 +01:00