You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
FilterList.apply_to_* truncate output at the first NUL byte #1507
FilterList.apply_to_buffer, apply_to_file and apply_to_blob return ffi.string(buf.ptr), which stops at the first NUL byte, so binary data comes back truncated.
It shows up for any binary file that gets a filter list, e.g. with core.autocrlf=true or * text=auto in .gitattributes. The crlf filter passes binary data through unchanged, and pygit2 then cuts it at the first NUL:
Seen in 1.19.2 through 1.21.0 (libgit2 1.9.7). In GitFourchette, the preview of an unstaged image in such a repo shows "0 × 0 pixels, 8 bytes".
Reading the buffer with its length fixes it: ffi.buffer(buf.ptr, buf.size)[:] in all three methods. With that change and a test that runs NUL bytes through all three, the suite passes (677 passed, 6 skipped). I can open a PR if you'd like.
Repository.raw_message (repository.py:1298) has the same ffi.string(buf.ptr) and cuts MERGE_MSG at a NUL. That one hardly matters, since git refuses to commit a message containing NUL.
Prepared with Claude Code; I reviewed the changes.
Activity
jorio commentedon Nov 5, 2026
@Grinv: Nice find. I wrote these filter functions, so that was my mistake. I would love to see the PR.
Keep NUL bytes in FilterList.apply_to_* output
Grinv commentedon Nov 5, 2026
Opened #1510. Besides the three
FilterListmethods it fixesRepository.raw_message, which had the same truncation.