PyLong_AsLong() returns -1 on error. The previous implementation
returned -1 when py_result was 0, which killed every .foreach()
iteration after the first callback.
We could skip the if clause and just return the result of
PyLong_AsLong(), but keeping the if clause makes it more obvious that
we *did* think about handling errors from PyLong_AsLong().
Signed-off-by: W. Trevor King <wking@tremily.us>
Config_foreach_callback_wrapper is supposed to return 0 on success.
From the docstring:
As soon as one of the callbacks returns an integer other than 0,
this function returns that value.
If we've already had an exception, we want to bail immediately and
raise the exception.
Signed-off-by: W. Trevor King <wking@tremily.us>
This brings us into compliance with the libgit2 commit:
commit 0ae81fc479bf3cf7ed31b3e3b070de7990102f1d
Author: nulltoken <emeric.fermas@gmail.com>
Date: Wed Oct 17 15:30:22 2012 +0200
index: remove read_tree() progress indicator
Signed-off-by: W. Trevor King <wking@tremily.us>
This brings us into compliance with the libgit2 commit:
commit bae957b95d59a840df72a725b06f00635471cfd8
Author: Russell Belfer <rb@github.com>
Date: Tue Sep 25 16:31:46 2012 -0700
Add const to all shared pointers in diff API
Signed-off-by: W. Trevor King <wking@tremily.us>
This fixes:
$ python setup.py build_ext --inplace
src/pygit2/config.c: In function ‘Config_foreach’:
src/pygit2/config.c:261:13: warning: passing argument 2 of ‘git_config_foreach’ from incompatible pointer type
../libgit2/include/git2/config.h:420:17: note: expected ‘int (*)(const struct git_config_entry *, void *)’ but argument is of type ‘int (*)(const char *, const char *, void *)’
Signed-off-by: W. Trevor King <wking@tremily.us>
This fixes:
src/pygit2/config.c: In function ‘Config_add_file’:
src/pygit2/config.c:276:5: error: too few arguments to function ‘git_config_add_file_ondisk’
Also convert `int priority` -> `unsigned int level` to match current
libgit2 header.
Signed-off-by: W. Trevor King <wking@tremily.us>
This fixes:
$ python setup.py build_ext --inplace
...
src/pygit2/config.c: In function ‘Config_get_multivar’:
src/pygit2/config.c:311:13: warning: passing argument 4 of ‘git_config_get_multivar’ from incompatible pointer type
../libgit2/include/git2/config.h:339:17: note: expected ‘int (*)(const struct git_config_entry *, void *)’ but argument is of type ‘int (*)(const char *, void *)’
error: command 'i686-pc-linux-gnu-gcc' failed with exit status 1
reported by wolftankk in issue #140.
Signed-off-by: W. Trevor King <wking@tremily.us>
To be more pythonic: merged methods create_reference and create_reference_symbolic
and added force-Option. To make a new symbolic reference you have provide symbolic=True
as an additional parameter. If force=True references will although be overridden.
Otherwise an exception is raised if the references exists.
Examples:
# normal reference
repo.create_reference('refs/heads/foo', repo.head.hex)
# override reference with new value
repo.create_reference('refs/heads/foo', repo.head.hex, force=True)
# symbolic reference
repo.create_reference('refs/tags/foo', 'refs/heads/master', symbolic = True)
Features:
- New 'Blob.size' getter
- New 'Repository.create_blob_fromfile' method
- Signature, now the time and offset parameters are optional
- Improved diff support
Other:
- Add 'pygit2.__version__'
- Optimize usage of Travis
- Various fixes for the unit tests
- Various documentation improvements
Thanks to Alex Chamberlain, Carlos Martín Nieto, Eric Davis,
Eric Schrijver, Petr Viktorin, Ridge Kennedy and W. Trevor King.
Moved the hardcoded version from setup.py to pygit2/version.py so
client software can figure out which version of pygit2 it's using.
Having setup.py import pygit2.version.__version__ removes duplication,
and also means that setup.py will always use the local version (and
not the version of a previously installed pygit2).
The previous test always passed, because bool(HEAD_SHA) is True.
The update to HEAD_SHA should have happened in:
commit c06e10e67e746099b8d454212acc56391199eb31
Author: Petr Hosek <p.hosek@imperial.ac.uk>
Date: Tue May 29 17:41:07 2012 +0100
Support for diff merge operation added
`git_revparse_single` only dates back to
commit ac250c56c7d7bb11691c9dfbcd0dbf580d85e177
Author: Ben Straub <bstraub@github.com>
Date: Wed Apr 25 16:24:22 2012 -0700
First stab at implementation of rev-parse.
which is not included in libgit2 0.17.0. We need to pull in these
patches to work with the current `development` branch of libgit2,
which does include the revparse code.
In both cases, the file contents change from 'X contents\n' to 'X
contents 2\n' (where 'X' is 'a' or 'b'). This means were removing one
line and adding another.
I'm not sure how this test was passing against libgit2 v0.17.0, so I
may be missing something important.
This catches up with changes in libgit2:
commit 9d7ac675d06dab2e000ad32f9248631af0191f85
Author: nulltoken <emeric.fermas@gmail.com>
Date: Tue Aug 21 11:45:16 2012 +0200
tree entry: rename git_tree_entry_attributes() into git_tree_entry_filemode()
This catches up with changes in libgit2:
commit 4bf5115642b64851f9a32a8157010b588bf44103
Author: Ben Straub <bstraub@github.com>
Date: Mon Jul 30 14:52:46 2012 -0700
Enable stats on git_index_read_tree.
Replace with the contents of
git_index_read_tree_with_stats() and improve
documentation comments.
This catches up with changes in libgit2:
commit f335ecd6e126aa9dea28786522c0e6ce71596e91
Author: Russell Belfer <rb@github.com>
Date: Thu Aug 30 14:24:16 2012 -0700