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.