libgit2 / pygit2

Python bindings for libgit2
https://www.pygit2.org/
Other
1.61k stars 385 forks source link

Using `Repository.apply()` segfaults #1033

Closed webknjaz closed 4 years ago

webknjaz commented 4 years ago

I use pygit2 from a wheel. The details of what I see are below:

$ python -X faulthandler
Python 3.8.5 (default, Sep  8 2020, 18:53:05) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygit2
>>> pygit2.__version__
'1.2.1'
>>> repo = .pygit2init_repository('test-repo.git')
>>> repo.apply('HEAD')
Fatal Python error: Segmentation fault

Current thread 0x00007fe0d3da2740 (most recent call first):
  File "<stdin>", line 1 in <module>
[1]    1831848 segmentation fault (core dumped)  python -X faulthandler
webknjaz commented 4 years ago

@jdavid what is the correct argument type? I haven't found what works for this method

jdavid commented 4 years ago

A Diff object. An example from test/test_repository.py:

diff = pygit2.Diff.parse_diff(patch)
testrepo.apply(diff)
webknjaz commented 4 years ago

@jdavid interesting... Do you think it's possible to emulate backport/chery-pick with applying a patch this way?