-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Blob::size()
#462
Add Blob::size()
#462
Conversation
@@ -34,6 +34,11 @@ impl<'repo> Blob<'repo> { | |||
} | |||
} | |||
|
|||
/// Get the size of this blob. | |||
pub fn size(&self) -> usize { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to choose usize
instead of git_off_t
? I think (although unlikely) this will silently truncate on 32-bit systems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it should be a 64-bit integer type, but I'm quite confused which type should be used here. git2 doesn't seem to return any value of a "raw" type (like git_off_t
) so I picked u64
, as a size should be an unsigned integer.
Co-Authored-By: Eric Huss <eric@huss.org>
Hm so actually, I might disagree with the |
(or maybe this is an API bug in libgit2 by exposing the ability to load any blob in-memory) |
If I understand the code of libgit2 correctly, libgit2 will read the data (ie. the contents of a blob) into memory, so this indeed looks like a flaw. However, since git by design supports large blobs, returning |
We already have an API that looks like |
This reverts commit 0517063.
Fair enough. I've reverted the last commit. |
@ehuss, to confirm, are you ok with the |
Oh, yea, seems fine to me! |
I hope this is trivial enough. :-)