Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repository.apply causes segfaults or assertion failures when anything except a Diff is passed in #1037

Closed
MathSquared opened this issue Oct 1, 2020 · 1 comment

Comments

@MathSquared
Copy link

The apply method of a Repository fails ungracefully when I give it anything other than a Diff object. Specifically, when I pass in a Patch, the assertion (repo && diff) fails, even though the documentation says apply can accept a diff or a patch. When I pass in a string, the application simply segfaults.

Repro:

from pygit2 import Repository
r = Repository('path/to/repository')
r.apply('foo')  # segfault

Though I use 'foo' in this test, the same result arises if I pass in the string form of a Git diff.

I would expect pygit2 to coerce a string or Patch to a Diff, or at least to raise a Python exception instead of allowing the C backend to throw an error and crash the application.

jdavid added a commit that referenced this issue Oct 3, 2020
@jdavid
Copy link
Member

jdavid commented Oct 3, 2020

The segfault was already reported in issue #1033 and fixed with commit 23a4dd6, which has been released in v1.3.0

Traceback (most recent call last):
  File "issue1037.py", line 3, in <module>
    r.apply('foo')  # segfault
TypeError: argument 1 must be _pygit2.Diff, not str

In commit 9d7e512 I've fixed the documentation.

Regarding coercing to a Diff, PRs are welcome.

@jdavid jdavid closed this as completed Oct 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants