I have a bunch of object ids referring to blobs in a given git repository. I would like to obtain the number of bytes that their uncompressed content occupies, preferably using JGit. That is, the number of bytes that the corresponding file will contain, once checked out in the workspace.
Is this information stored in the git blob itself? It is briefly discussed here but I do not understand if the blob size in the blob header corresponds to the size once inflated, or something else (such as the size required to store the delta).
I can access the blob size through JGit: given a FileRepository repository
and having initialized once and for all an ObjectLoader reader = repository.newObjectReader()
, it seems that the size I seek can be obtained using reader.open(objectId).getSize()
. But this is slow. It often takes several tens of milliseconds to get a blob size. If I understand correctly, JGit reads the whole blob, at least in some cases. (I asked a similar question here but got no reply.)
My question is: can I get a blob size faster using JGit? Alternatively, can I achieve what I want at least in principle by reading some part of the blob data, that is, is this information stored somewhere in direct form, or deducible, or do I absolutely need to read and inflate the whole blob before knowing its size?