libgit2/libgit2sharp — pull request #724 by carlosmn (2014-05-29 11:56:58+00:00)
Title: Write directly to the ODB when possible

While trying to get rid of the uglyness that is `git_blob_create_fromchunks()`, I realised we can do it bit by bit, so here's the first bit.

If we're given no path (and thus cannot do any filtering) and a size, we know that we can stream the data directly into the database, so let's do that with a `git_odb_stream`.

This brought up the fact that we expect a short read to succeed, which is only possible because `fromchunks` waits for an EOF signal from us, which we can simply pass along from `Stream.Read()`. Trying to keep this behaviour would make it impossible to optimise anything, and it also seems like a great place to introduce subtle bugs, so I've changed the tests to reflect that we need to read that amount of bytes.

This however is still the behaviour for the case when we have a path, since that needs filtering and thus must still rely on `fromchunks`. This however means that the place where we would raise the exception is beyond a C wall, so that probably wouldn't work without storing the exception somewhere.