234 Commits

Author SHA1 Message Date
Carlos Martín Nieto
139034f66f Support short OIDs
Intoduce and use py_str_to_git_oid_expand() to get a full OID from a
short one the user may have passed.

Repository_contains() has learnt to do it by itself as expanding an
OID means asking the repository's ODB for the object anyway.

The return values have been made consistent with other functions and
py_str_to_git_oid() now returns an int and marks errors with a
negative value.
2012-03-15 05:33:13 +01:00
J. David Ibáñez
b1508a31eb Merge remote branch 'bos/safe_message' 2012-03-14 23:16:00 +01:00
Yonggang Luo
a444cd1e1c utils.py Use onerror deal with rmtree 2012-03-14 22:59:16 +01:00
Bryan O'Sullivan
d35944cc7d Decode messages leniently if encoding is not known
This avoids throwing of a UnicodeDecodeError on some really old commits.

We also add undecoded attribute accessors, to get at the raw bytes.
2012-03-13 16:21:42 -07:00
J. David Ibáñez
a0810694ed Merge remote branch 'carlos/treebuilder' 2012-03-12 22:30:30 +01:00
J. David Ibáñez
a6a36ad803 Now TreeEntry points back to the repo
Instead of pointing back to the tree.
2012-03-11 22:50:55 +01:00
J. David Ibáñez
f11533a65a Revert "(issue #56) Remove TreeEntry.to_object"
This reverts commit 4cdb1a83b430fa27e2b0800ce17751631b036a78.
2012-03-11 22:40:37 +01:00
J. David Ibáñez
6dd8ec65a9 (issue #75) Include readme file in source dist
Patch submitted by rl-0x0
2012-03-09 23:15:08 +01:00
Carlos Martín Nieto
242f3c2ffa TreeBuilder: allow the source to be a Tree
If the user passes a tree, use it as the source for the
TreeBuilder. On the way, make sure we free the tree we looked up, and
fix a test to make sure the TreeBuilder starts empty.
2012-03-09 12:57:22 +01:00
Carlos Martín Nieto
3e73d3a2b8 Add remove() and clear() to TreeBuilder 2012-03-09 11:41:17 +01:00
Carlos Martín Nieto
eb522b0caa Make TreeBuilder grow out of the repository
A TreeBuilder is a lot more useful (and easy to use) when it belongs
to a repository.
2012-03-09 11:41:17 +01:00
J. David Ibáñez
8380c625c4 Check for error after call to py_str_to_c_str
Fixes segfaults in 'Repository.create_commit' and 'Signature(...)'
Error reported by Han-Wen Nienhuys in the mailing list.
2012-03-03 17:37:33 +01:00
J. David Ibáñez
c6ebc98930 Revert "Commit.parents now returns a list of oids"
This reverts commit 1fb34e7b96000d29c4633b66fabc0699ac74ce15.
2012-02-28 13:02:37 +01:00
J. David Ibáñez
1fb34e7b96 Commit.parents now returns a list of oids
Instead of returning the commit objects.
2012-02-27 00:25:57 +01:00
J. David Ibáñez
4b0f759cc0 Tag.target now returns the oid (not the object) 2012-02-27 00:13:43 +01:00
J. David Ibáñez
e9e902e024 tests: add utility function 'oid_to_hex' 2012-02-27 00:12:33 +01:00
J. David Ibáñez
8b84f90a81 (issue #56) Fix TreeBuilder deallocation
Also, add a comment to the TODO file about a memory management issue
found throught pygit2.
2012-02-26 19:57:33 +01:00
J. David Ibáñez
4cdb1a83b4 (issue #56) Remove TreeEntry.to_object
This is one way to enable implementing 'TreeBuilder.get'. It also makes
pygit2 a little lower-level. And makes TreeEntry consistent with IndexEntry,
which lacks such a function.
2012-02-26 19:41:17 +01:00
Amit Bakshi
b1cb51c9d1 Test for pygit2.discover_repository 2012-02-25 18:15:45 -08:00
Amit Bakshi
7ad8f0a8f0 Add discover_repository.
pygit2.discover_repository(path, across_fs = False,
                           ceiling_paths = None)

Add support for git_discover_repository which
searches the given path for the git repository.
2012-02-25 17:33:59 -08:00
Carlos Martín Nieto
cf380cea2a Add tests for TreeBuilder 2012-02-21 12:36:51 +01:00
Carlos Martín Nieto
8b71a8045b Allow a 'source' arg to TreeBuilder() 2012-02-21 12:36:51 +01:00
Carlos Martín Nieto
2044699a53 Add TreeBuilder_write 2012-02-21 12:36:51 +01:00
Carlos Martín Nieto
5d327c7205 Add TreeBuilder_insert 2012-02-21 12:36:51 +01:00
Carlos Martín Nieto
d43577a464 Create the TreeBuilder type 2012-02-21 12:36:38 +01:00
J. David Ibáñez
7e1e8435aa todo: add note about surrogateescape 2012-02-19 17:13:33 +01:00
J. David Ibáñez
b143c0ccde Fix compilation warnings 2012-02-19 09:20:58 +01:00
Yonggang Luo
5da739270a Arrange Tree and Index definition. 2012-02-18 17:10:08 +08:00
Yonggang Luo
5ece88300a Repository_create_tag return error when necessary. 2012-02-18 16:28:35 +08:00
Yonggang Luo
8394dfb814 Remove extra print. 2012-02-16 01:02:55 +08:00
Yonggang Luo
2b4e5504af Get pygit2 can be build under Windows. 2012-02-16 01:00:49 +08:00
J. David Ibáñez
3bf5b4c794 status: new method 'Repository.status_file'
Exposes libgit2 function 'git_status_file'.
2012-02-10 19:38:25 +01:00
J. David Ibáñez
f11a05b610 docs: fix for the previous commit 2012-02-08 23:29:27 +01:00
J. David Ibáñez
a11f3c52a9 docs: use readme file for both github and pypi
The readme file is now written in reStructuredText (instead of
markdown). This is because reST is the only thing pypi understands.

So now the same readme file will be used for pygit2's homepage at github
and pypi:

- https://github.com/libgit2/pygit2
- http://pypi.python.org/pypi/pygit2
2012-02-08 23:21:37 +01:00
J. David Ibáñez
0fa8503f91 Release v0.16.0
Changes since v0.15.1:

- Update to libgit2 v0.16.0
- Improve support for references
- New method Index.read_tree
- Rename Index.create_tree to Index.write_tree
- Fix compilation error with MSVC (issue #53)
- Fix a few segfaults (including issue #55)
v0.16.0
2012-02-06 23:30:00 +01:00
J. David Ibáñez
42006d7153 docs: update talk about signatures 2012-02-06 23:05:19 +01:00
Carlos Martín Nieto
bc7db4ba8a errors: don't segfault if the library didn't set an error
git_lasterror() can return NULL. Passing that to the error formatting
functions leads to a segmentation fault.

Add a wrapper with a generic "no more information" string for the
cases when the library didn't set one.
2012-02-03 18:33:48 +01:00
J. David Ibáñez
39bb5de7c5 Fixing compilation with MSVC (issue #53) 2012-01-25 19:04:16 +01:00
J. David Ibáñez
9d8d2ace64 index: implement Index.read_tree 2012-01-02 23:11:30 +01:00
J. David Ibáñez
550c966111 Rename Index.create_tree to Index.write_tree
Like Git command "git write-tree"
2012-01-02 20:10:28 +01:00
J. David Ibáñez
35ed84cf44 Update to latest changes in libgit2
Now Repository.index also works on bare repositories. Unit tests pass
again.

And fix a memory leak (add a call to git_index_free).
2012-01-02 19:42:49 +01:00
J. David Ibáñez
4a33c7f806 refs: implement reference reload 2011-12-25 10:46:38 +01:00
J. David Ibáñez
73a4a3a649 refs: resolving a direct ref returns the same object
When resolving a direct reference the same Python object is returned,
with the refcount incremented by one. The reference is reloaded.
2011-12-24 17:04:24 +01:00
J. David Ibáñez
584a8b1473 refs: implement reference dealloc 2011-12-20 22:19:15 +01:00
J. David Ibáñez
5986688197 refs: fix segfault when using a deleted reference
Before this patch the code below produced a segfault:

  >>> reference.delete()
  >>> reference.name

Now an exception is raised.
2011-12-19 23:40:27 +01:00
J. David Ibáñez
01cb80b4c8 errors: pass through git_lasterror in several places
And clean up related code a little bit.
2011-12-06 23:36:20 +01:00
J. David Ibáñez
2dee35d1be Update to latest changes in libgit2 2011-12-04 23:38:15 +01:00
J. David Ibáñez
3073a7c3da Return bytes for paths (and encodings) on Python 2 v0.15.1 2011-11-28 23:33:16 +01:00
J. David Ibáñez
1a34bc3b60 Update .gitignore, add test/__pycache__
The __pycache__ folder is genarated by Python 3.2
2011-11-28 22:47:35 +01:00
J. David Ibáñez
3037d26c9d Fix unit tests with Python 3.2 2011-11-27 10:05:58 +01:00