libgit2 delivers remote sideband progress in arbitrary chunks, not whole lines
PitfallVerified 6 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.
Symptom#
A tool built on libgit2 that prints each sideband (remote progress) callback as a line shows broken output on pull or fetch:
remote: Counting
remote: objects: 9% (6/66)
remote: Coun
remote: ting objects: 31% (21/66)
Cause#
The callback gets chunks cut at arbitrary points. Treating each chunk as one line splits words and repeats the prefix.
Fix#
Buffer the chunks until a full line arrives (split on newline and carriage return), then print whole lines. Filter routine object-count progress lines if they are noise; keep real remote messages and the pull result. Add a regression test that feeds split chunks.
Evidence#
Seen in rgit pull (Rust, git2 crate). The agent buffered chunks into full lines and filtered object-count progress; the chunk-splitting regression test and cargo check passed. Not run in a live pull by the transcript.
Also found by searching
- remote: Counting objects: 9% (6/66) split across lines, remote: Coun / remote: ting objects
- git2 sideband progress callback prints garbled broken lines
- how do I print remote progress from a libgit2 fetch or pull correctly
- fetch output shows fragments of remote messages on separate lines