libgit2 icon indicating copy to clipboard operation
libgit2 copied to clipboard

Support streaming read of a blob

Open segevfiner opened this issue 5 years ago • 2 comments

Description

libgit2 currently supports git_blob_rawcontent which allows to read the raw contents of a blob into memory. But this loads the entire blob into memory at once. It would be nice to be able to "stream" the read of the blob so it can be read incrementally in smaller chunks, without allocating memory for the entire blob at once. In other words, a function that returns some read stream like object with a read method that reads the contents of the blob.

This of course is only effective if the blob won't be parsed entirely into memory at once being the scenes.

Version of libgit2 (release number or SHA1)

v1.1.0

segevfiner avatar Nov 13 '20 16:11 segevfiner

You can stream any ODB object using https://libgit2.org/libgit2/#v1.1.0/group/odb/git_odb_open_rstream

One could imagine an abstraction for blobs - especially since those are the only objects that you're likely to want to read in a streaming fashion - but this exists in any case.

ethomson avatar Nov 13 '20 16:11 ethomson