1353 Commits

Author SHA1 Message Date
J. David Ibáñez
cb0f9d4e75 travis: use trusty dist 2017-05-07 13:47:29 +02:00
Lukas Fleischer
f18de427bf Randomize OID object hashes
Instead of using type punning to convert the OID to a Python hash, use
_Py_HashBytes() to hash the OID again. This means we no longer make any
assumptions on the internal representation of OID values or Python
hashes (before this commit, we at least relied on the fact that OID
hases are longer than Python hashes). Moreover, the random seed stored
in PYTHONHASHSEED is now honored.

This also fixes a compiler warning seen with -Wstrict-aliasing.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
2017-05-07 10:03:17 +02:00
J. David Ibáñez
f841c62fa6 Drop support for Python 3.2, cffi 1.10 doesn't work with 2017-05-07 09:53:10 +02:00
Lukas Fleischer
035d4a9396 Mark index unsigned in get_pylist_from_git_strarray()
Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
2017-05-07 07:47:00 +02:00
Lukas Fleischer
21d668421f Remove unused variable from Repository_init()
Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
2017-05-07 07:44:01 +02:00
Lukas Fleischer
b88dc86842 Fix parameter passing of describe patterns
When ffi.new() is used to build a new pointer object, the returned
pointer object has ownership on the allocated memory. When it is
garbage-collected, then the memory is freed. Thus, we need to make sure
the original object survives its use, otherwise the casted pointer will
point to garbage.

This fixes one test which was failing with the latest CFFI version, see
issue #694. Thus, this commit also reverts 803b1cb (cffi 1.10 not yet
supported, 2017-03-22) where the latest CFFI version was marked as
unsupported.

Signed-off-by: Lukas Fleischer <lfleischer@lfos.de>
2017-05-06 21:49:47 +02:00
J. David Ibáñez
8559b2da20 Release 0.25.1 v0.25.1 2017-04-25 19:08:10 +02:00
J. David Ibáñez
9325494d6f docs: fix references 2017-04-21 11:36:40 +02:00
J. David Ibáñez
74717bed55 Merge remote-tracking branch 'tmr232/references-object' 2017-04-21 11:13:09 +02:00
Tamir Bahar
3818555e14 Added Repository.references accessor. 2017-04-21 08:51:41 +00:00
J. David Ibáñez
706c60c4ab Clean some cffi warnings
"has no values explicitly defined"
2017-04-20 22:32:03 +02:00
J. David Ibáñez
0733ba4da3 docs: fix make html 2017-04-19 21:34:07 +02:00
Tamir Bahar
320ee5e733 Added GIT_BRANCH_ALL 2017-04-19 21:10:11 +03:00
Tamir Bahar
d6716e035a Updated docs to match new branches API. 2017-04-19 21:03:43 +03:00
Tamir Bahar
d14438725e Added basic Repository.branches implementation. 2017-04-17 23:02:58 +03:00
J. David Ibáñez
dd57c9b366 Fixing error on Python 2.7 / Windows 64bits 2017-04-09 13:11:50 +02:00
J. David Ibáñez
f2c89a760a (partial) review the way we handle Python int/long 2017-04-09 12:33:24 +02:00
J. David Ibáñez
f37cf25b8e Fix warning, and coding style a bit 2017-04-08 16:56:04 +02:00
J. David Ibáñez
11ff7a99eb Options, improve error messages 2017-04-08 11:16:15 +02:00
J. David Ibáñez
9335819795 Opening repos, raise more meaningful exceptions 2017-04-05 22:18:21 +02:00
Tamir Bahar
784583d21e Fixed indentation 2017-04-05 21:59:30 +03:00
Tamir Bahar
b81810e9cb Better error messages for opening repos.
Closes #645.
2017-04-05 20:59:36 +03:00
Tamir Bahar
7ee851273a Added explicit check for path = None in init_repository
Closes #688.
2017-04-05 16:37:25 +03:00
Nick Hynes
453fd8a9a3 Add docs 2017-03-27 17:10:51 -04:00
Nick Hynes
630d905e73 Add stash tests 2017-03-27 17:10:45 -04:00
Nick Hynes
9be907983f Wrap stash_pop 2017-03-27 16:42:38 -04:00
Nick Hynes
b31ac50210 Wrap stash_drop 2017-03-27 16:33:32 -04:00
Nick Hynes
da233b16c5 Wrap git_stash_apply 2017-03-27 16:31:21 -04:00
Nick Hynes
1a842ff8bd Wrap git_stash_save 2017-03-27 16:20:33 -04:00
Nick Hynes
cbbf9f1f87 Fix Signature._pointer 2017-03-27 16:18:21 -04:00
Nick Hynes
a294655aa5 Add declarations for git-stash 2017-03-27 16:18:13 -04:00
J. David Ibáñez
5a940987cd Add support for Python 3.6 2017-03-22 21:45:12 +01:00
J. David Ibáñez
354d56a95c Update copyright years 2017-03-22 21:15:34 +01:00
Jason Ziglar
8327e1bee3 Add test for init_submodules() and update_submodules() 2017-03-22 11:23:17 -04:00
Jason Ziglar
15326b731f Add update_submodules() command 2017-03-22 11:23:17 -04:00
Jason Ziglar
f5cd6da307 Add init_submodules() command 2017-03-22 11:23:17 -04:00
J. David Ibáñez
803b1cb154 cffi 1.10 not yet supported 2017-03-22 16:01:23 +01:00
J. David Ibáñez
d622e87654 test options, avoid side effects
This makes tests in PR#692 to pass
2017-03-22 13:38:11 +01:00
J. David Ibáñez
819cbff552 Remove some tabs 2017-02-09 17:31:50 +01:00
Matthaus Woolard
4fbc1f1c05 Add support for custom backends
Signed-off-by: Matthaus Woolard <matthaus.woolard@gmail.com>
2017-02-09 15:57:56 +00:00
Tamir Bahar
5c061cbb0a Remove unused code
Removed a chunk of code from `checkout` that did nothing, but had a bug.
When checking out from a branch-less state (like the state when a repository is first initialized) the code failed.
The failure was due to trying to get some properties of the current branch, which were never used in the code.
2017-01-03 01:17:48 +02:00
J. David Ibáñez
68817aad4f Release 0.25.0 v0.25.0 2016-12-26 12:30:36 +01:00
J. David Ibáñez
0b513d57fa Merge remote-tracking branch 'carlos/next' 2016-12-23 21:37:58 +01:00
Carlos Martín Nieto
074a726d7f Update versions to libgit2 v0.25.0 2016-12-23 20:24:37 +00:00
J. David Ibáñez
950249442e Merge remote-tracking branch 'bisho/master' 2016-12-20 20:02:47 +01:00
Guillermo Pérez
809fe33b8a Make pygit2 throw if tree of a commit is not found
Commit objects in git always have a tree_id associated, that points
to the corresponding Tree object.

When the tree object is missing, the repo is corrupted.

In those cases:
* official git cli fatals with status code 128 and message:
  fatal: unable to read tree <hash>
* libgit2 returns error GIT_ENOTFOUND when calling git_commit_tree()
* pygit2 when accessing the tree by id with repo[commit.tree_id]
raises a KeyError: <hash>

But on the other hand, on the commit object, rather than throwing
and exception, pygit2 is swallowing the error returned by libgit2
and setting the <Commit object>.tree property to None.

None is arguable the wrong choice to encode an error condition,
specially in python that is used heavily.

In particular this caused in our system to assume there was
an empty tree, and the sync service that tails git repo changes
decided to DELETE everything. The code was using None to
represent empty tree, usefull for example when we need to
compare a path between two commits (the path might be non-existant
at one of the commits you are comparing).

I think that in this case the right decision would be to raise
since is an exceptional case, caused by a corrupted repo,
is more consistent with other tools, and ensures user code
does not take the wrong decissions.

For curiosity the corrupted repository can happen more commonly
than expected. We run our repositories on a shared NFS filer,
and one of our servers didn't have the lookupcache=positive
flag. This makes NFS cache the metadata (files on a directory
for example) and use that for negative lookups (to deny existance
of files). In this case, the commit object was on a directory
not cached, so the commit was seen immediately, but the tree
object was in a folder that was cached, the cache didn't
contained the tree object, and thus for some seconds the tree
was not existing and the repo was corrupted. Our sync service
saw tree being None and decided to delete everything, causing
a lot of issues down the way.
2016-12-19 11:28:00 -08:00
Szucs Krisztian
6402302002 fixed cached memory tests 2016-12-03 14:01:39 +01:00
Szucs Krisztian
77f0585645 Added mwindow_mapped_limit, cached_memory, enable_caching, cache_max_size, cache_object_limit options 2016-12-03 13:52:19 +01:00
Carlos Martín Nieto
acdec78617 Update for v0.24+1 2016-11-14 16:40:36 +01:00
J. David Ibáñez
66280af83a Release 0.24.2 0.24.2 v0.24.2 2016-11-01 20:34:50 +01:00