libgit2

git_blob_filtered_content

Version:

Get a buffer with the filtered content of a blob.

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_dispose).

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.

Signature

int git_blob_filtered_content(git_buf *out, git_blob *blob, const char *as_path, int check_for_binary_data);

Parameters

In
out

The git_buf to be filled in

In
blob

Pointer to the blob

const char *
In
as_path

Path used for file attribute lookups, etc.

int
In
check_for_binary_data

Should this test if blob content contains NUL bytes / looks like binary data before applying filters?

Returns

int

0 on success or an error code

Versions