Skip to content
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 docs for blob.jl #22555

Merged
merged 7 commits into from
Jul 8, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions base/libgit2/blob.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ end

Fetch the *raw* contents of the [`GitBlob`](@ref) `blob`. This is a read-only
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does read only mean here? you can always write to julia arrays

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did the revised wording make this clearer?

`Array` containing the contents of the blob, which may be binary or may be ASCII
`String` data.
`String` data. `rawcontent` will allow the user to load the raw binary data into
the output `Array` and will not check to ensure it is a valid `String`, so errors
may occur if the result is passed to functions which expect valid `String` data.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the result an array or a string? if this is type stable and always array, then you won't be passing it directly to most String functions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Counterpoint: just a few lines below, s = String(rawcontent(blob)) 😛

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the constructor yes, but not things that expect a String


See also [`content`](@ref).
See also [`content`](@ref), which *will* throw an error the content of the `blob`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

throw an error if the content

is binary and not valid ASCII.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it error on unicode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think it shouldn't, the libgit2 docs only refer to "printable characters"

"""
function rawcontent(blob::GitBlob)
ptr = ccall((:git_blob_rawcontent, :libgit2), Ptr{UInt8}, (Ptr{Void},), blob.ptr)
Expand Down