2.3 Blob
(require libgit2/include/blob) | package: libgit2 |
procedure
(git_blob_create_frombuffer id repo buffer len) → integer? id : oid? repo : repository? buffer : (cpointer void) len : integer?
procedure
(git_blob_create_fromdisk id repo path) → integer?
id : oid? repo : repository? path : string?
procedure
repo : repository? hintpath : string?
This function may need to buffer the data on disk and will in general not be the right choice if you know the size of the data to write. If you have data in memory, use git_blob_create_frombuffer(). If you do not, but know the size of the contents (and don’t want/need to perform filtering), use git_odb_open_wstream().
Don’t close this stream yourself but pass it to git_blob_create_fromstream_commit() to commit the write to the object db and get the object id.
If the hintpath parameter is filled, it will be used to determine what git filters should be applied to the object before it is written to the object database.
procedure
(git_blob_create_fromstream_commit out stream) → integer? out : oid? stream : writestream?
The stream will be closed and freed.
procedure
(git_blob_create_fromworkdir id repo relative_path) → integer? id : oid? repo : repository? relative_path : string?
procedure
(git_blob_filtered_content out blob as_path check_for_binary_data) → integer? out : buf? blob : blob? as_path : string? check_for_binary_data : boolean?
This applies filters as if the blob was being checked out to the working directory under the specified filename. This may apply CRLF filtering or other types of changes depending on the file attributes set for the blob and the content detected in it.
The output is written into a git_buf which the caller must free when done (via git_buf_free).
If no filters need to be applied, then the out buffer will just be populated with a pointer to the raw content of the blob. In that case, be careful to not free the blob until done with the buffer or copy it into memory you own.
procedure
(git_blob_free blob) → void?
blob : blob?
This is a wrapper around git_object_free()
IMPORTANT: It is necessary to call this method when you stop using a blob. Failure to do so will cause a memory leak.
procedure
(git_blob_is_binary blob) → boolean?
blob : blob?
The heuristic used to guess if a file is binary is taken from core git: Searching for NUL bytes and looking for a reasonable ratio of printable to non-printable characters among the first 8000 bytes.
procedure
(git_blob_rawcontent blob) → bytes?
blob : blob?
A pointer to the raw content of a blob is returned; this pointer is owned internally by the object and shall not be free’d. The pointer may be invalidated at a later time.