libgit2 / pygit2

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

GitError raised on parsing a diff that has a filename with spaces #1260

Open 2bndy5 opened 6 months ago

2bndy5 commented 6 months ago

This was raised originally at cpp-linter/cpp-linter-action#178 in which a large diff was parsed by pygit2.Diff.parse_diff() (on ubuntu-latset CI github runner).

The error says:

pygit2.GitError: trailing data at line 3734

Here's the full diff: full_pr.diff.txt which was generated by github with the URL https://github.com/edunad/rawrbox/pull/108.diff

Line 3734 is

rename from render/content/fonts/SIL Open Font License.txt

I was able to reproduce this error locally on Windows. Is this expected behavior?

If I remove the spaces from the file name or put the entire path in quotes, then the diff is parsed without problem.

2bndy5 commented 6 months ago

I tried to parse the diff in the rust binding git2-rs and got the same error, so I think this a problem with libgit2 C library itself.

This seems similar to libgit2/libgit2#5029 except the space is in a renamed filename.