libgit2/libgit2 — pull request #1042 by pwkelley (2012-11-02 18:37:49+00:00)
Title: Fix bytes_received in fetch tests - we weren't calling the callback

I had failed to account for two things here:
1. There could be data in the buffer already from the `negotiate_fetch` step.
2. The callback might never fire if the threshold is not reached. Fixed by adding a trailing call to the callback on our way out, if the byte count is greater than what it was the last time we fired the callback.

Also cleaned up the error handling in the function a little bit.