457 Commits

Author SHA1 Message Date
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
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
3cc129dd62 Merge remote-tracking branch 'origin/cffi-remote' 2014-04-18 21:56:00 +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
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
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
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
e5f6798f67 Adjust to oid -> id renaming 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
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
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
Carlos Martín Nieto
b49da53962 Introduce credentials 2014-03-26 12:10:24 +01:00
Carlos Martín Nieto
48ff3a8983 Create proxy object for libgit2 options
pygit2.settings proxies though the lower-level varargs option() via
getters and setters which provide a more natural abstraction.
2014-03-23 15:53:32 +01:00
Carlos Martín Nieto
ab44196730 Introduce libgit2 options
Allow setting and getting the mwindow size and search paths.
2014-03-23 15:23:42 +01:00
Leonardo Rhodes
1a17256ee3 added unit test 2014-02-13 23:09:40 +01:00
J. David Ibáñez
56a2f0f9a8 Merge remote-tracking branch 'carlos/object-peel' 2014-02-11 19:07:40 +01:00
Carlos Martín Nieto
b2cd25cf00 object: allow passing a type object to peel()
Allow usage of a python type instead of having to use the libgit2
constants.
2014-02-11 18:30:47 +01:00
Carlos Martín Nieto
de3dba668a object: implement peel()
This simplifies getting one type of object from a higher-level one as
well as accepting a commit-ish or tree-ish.
2014-02-11 18:30:47 +01:00
Carlos Martín Nieto
1f3c0170aa test: clean up
Remove the temporary files and directories we create as part of running
the test suite.
2014-02-11 17:53:31 +01:00
Carlos Martín Nieto
73170cc104 walk: make the sorting mode optional
Since the libgit2 has a default sorting method, which we also mention as
default in the documentation, there is no particular need to make the
user choose a sorting method when the order does not matter. We use
sorting NONE in that case.
2014-02-06 10:46:30 +01:00
J. David Ibáñez
d7071b88cd Update copyright year 2014-02-04 08:02:12 +01:00
J. David Ibáñez
977c315c21 Preparing for release 2014-02-02 15:07:47 +01:00
J. David Ibáñez
6a8e7a97cb Merge remote-tracking branch 'carlos/index-add-entry' 2014-01-29 11:57:44 +01:00
Carlos Martín Nieto
f3f3d28637 Index: allow writing the tree to a particular repository
Take an optional repository in Index.write_tree() to serialize to a tree
into a particular repository's odb.
2014-01-29 11:46:53 +01:00
Carlos Martín Nieto
c43c320c3e Index: accept adding either a path or an IndexEntry
A path is only useful if we have the file on the worktree. Passing an
IndexEntry allows us to add an entry with arbitrary attributes.
2014-01-29 11:46:53 +01:00
Carlos Martín Nieto
f6389ee2c3 IndexEntry: make the attributes writable
When updating entries in an index, it is necessary to modify the
attributes of tree entries. make it possible to do so.
2014-01-29 11:46:53 +01:00
J. David Ibáñez
3026798add Merge remote-tracking branch 'carlos/pypy' 2014-01-27 22:58:47 +01:00
Carlos Martín Nieto
30084e00c4 Add support for pypy
Fortunately pypy provides support for a lot of the CPython API, so the
changes are minimal.

The most important changes are:

- constructors always get a keyword argument dictionary, even if no
  keyword arguments are passed

- trying to assign to a read-only attribute raises TypeError instead of
  AttributeError

Apart from that, pypy does not provide MAXPATHLEN. There is a hack in
place currently, but there is only place that's using that macro, and
there shouldn't be a need for it much longer.

This fixes #209.
2014-01-26 09:52:35 +01:00
Carlos Martín Nieto
c2b2c5dd16 remote: call user-provided callbacks
The user can set 'progress', 'transfer_progress' and 'update_tips' to be
notified whenever one of those happen.
2014-01-25 10:48:49 +01:00
Carlos Martín Nieto
5410128187 TreeEntry: move to use 'id' attribute for the object's id
Similar to the Object change, we should be using 'id' when referring to
the target's id.x
2014-01-24 11:25:39 +01:00
Carlos Martín Nieto
500a6793c4 Object: move to use an 'id' attribute instead of 'oid'
This looks like a left-over from the libgit2 misnaming. The current
consensus is that 'oid' is the data type and 'id' is the name of the
attribute.
2014-01-24 11:04:34 +01:00
Carlos Martín Nieto
3a83cb44b6 Oid: Deprecate 'hex' in favour of str() or unicode()
Python has built-in functions to get a string representation of an
object id, so let's use that instead of using a custom attribute.
2014-01-24 10:28:53 +01:00
Carlos Martín Nieto
0c3a700e30 Remote: harden the resfpec setters
The object passed must be a list of strings, so make sure we fail by
raising an error instead of segfaulting.
2014-01-22 23:30:02 +01:00
Carlos Martín Nieto
1040a6330a Remote: make fetch/push_refspecs attributes
This is a lot more pythonic than two sets of getter-setter
functions. The old ones are left for backwards compatibility but they
should be removed in the next release.
2014-01-22 23:06:52 +01:00
XTao
9ef75d846e Add fetch & push refspec. 2014-01-22 15:25:25 +08:00
J. David Ibáñez
b27b10eb56 Merge remote-tracking branch 'carlos/tree-deep-search' 2014-01-20 10:48:23 +01:00
J. David Ibáñez
4c28c487db Merge remote-tracking branch 'carlos/push-url' 2014-01-20 10:45:27 +01:00
Carlos Martín Nieto
5baaf287d2 Tree: let contains look in subtrees
Allow looking in subtrees as a convenience in the 'contains'
function. As slashes are not allowed to be part of the name of an entry,
there is no ambiguity in what they mean.
2014-01-20 03:37:59 +01:00
Carlos Martín Nieto
e28c06fc1d Remote: allow access to the push url 2014-01-20 03:17:34 +01:00
Carlos Martín Nieto
17a49bb417 Refspec: implement transform functions 2014-01-19 23:59:47 +01:00
Carlos Martín Nieto
e681a47245 Refspec: create the type to wrap refspecs 2014-01-19 23:59:26 +01:00
J. David Ibáñez
73518fd804 Merge remote-tracking branch 'carlos/treeentry-cmp' 2014-01-19 20:09:22 +01:00
J. David Ibáñez
5bca48ee57 Merge remote-tracking branch 'carlos/config-iterator' 2014-01-19 20:00:46 +01:00
J. David Ibáñez
8090a11530 Merge remote-tracking branch 'carlos/commit-attr-id' 2014-01-19 19:51:33 +01:00
Carlos Martín Nieto
35386cbec2 Config: switch from foreach iterator
An iterator is much more natural in python, so let's use that.
2014-01-19 17:57:26 +01:00
Carlos Martín Nieto
4dc90f78a9 TreeEntry: add rich comparison function
Allow direct comparisons between TreeEntry objects, which also allows us
to use assertEqual in the sanity check test.

This fixes #305.
2014-01-19 17:10:40 +01:00