Closed chenrui333 closed 2 years ago
@adamgolebiowski any chance of merging this?
For this to be merged CI must be updated to use 1.2 instead of 1.1
These lines at least:
https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/.travis.yml#L32
https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/Makefile#L4
https://github.com/libgit2/pygit2/blob/25f035b5088df48cec2b55c520497f6587af44b8/appveyor.yml#L38
Having tried to apply this PR as a patch, it looks like it builds but a large portion of the test suite starts failing with errors like this:
ffi.error: struct git_remote_callbacks: wrong offset for field 'payload' (cdef says 96, but C compiler says 104). fix it or use "...;" as the last field in the cdef for struct git_remote_callbacks to make it flexible
Yea, libgit2 added a new field to the git_remote_callbacks
struct in https://github.com/libgit2/libgit2/commit/72df17c659619707e4e5f27b2a51db60848a1d04#, so the offset for the payload
field should indeed be 104.
@carlocab Any chance you can make that adjustment in this PR?
I'm not familiar enough with the code here to know what the right adjustment is. Do you have a backtrace for the error you saw?
Here is the first of 12 failed / 14 errors I get when applying this PR as a patch to 1.6.1 sources, then building against libgit2-1.2.0, then running python setup.py pytest
:
==================================== ERRORS ====================================
__________________ ERROR at setup of test_branches_remote_get __________________
emptyrepo = pygit2.Repository('/tmp/pytest-of-builduser/pytest-0/test_branches_remote_get0/emptyrepo/.git/')
@pytest.fixture
def repo(emptyrepo):
remote = emptyrepo.remotes[0]
> remote.fetch()
test/test_branch_empty.py:36:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pygit2/remote.py:141: in fetch
with git_fetch_options(callbacks) as payload:
/usr/lib/python3.9/contextlib.py:119: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
payload = <pygit2.callbacks.RemoteCallbacks object at 0x7fdcd1673ac0>
opts = None
@contextmanager
def git_fetch_options(payload, opts=None):
if payload is None:
payload = RemoteCallbacks()
if opts is None:
> opts = ffi.new('git_fetch_options *')
E ffi.error: struct git_remote_callbacks: wrong offset for field 'payload' (cdef says 96, but C compiler says 104). fix it or use "...;" as the last field in the cdef for struct git_remote_callbacks to make it flexible
pygit2/callbacks.py:247: error
____________________ ERROR at setup of test_branches_remote ____________________
emptyrepo = pygit2.Repository('/tmp/pytest-of-builduser/pytest-0/test_branches_remote0/emptyrepo/.git/')
@pytest.fixture
def repo(emptyrepo):
remote = emptyrepo.remotes[0]
> remote.fetch()
Thanks for the fix, @jdavid.
Here's https://github.com/libgit2/pygit2/commit/dcde9eff5950492ab0d2565a07fd18d765332a96 amended so that it applies to the PyPI tarball, in case anyone needs it:
relates to https://github.com/Homebrew/homebrew-core/pull/84518