Commit ad10db2a by Russell Belfer Committed by Philip Kelley

Check for binary blobs in checkout

This adds a git_buf_text_is_binary check to blobs before applying
filters when the blob data is being written to disk.
parent fcc48d1f
...@@ -685,19 +685,23 @@ static int blob_content_to_file( ...@@ -685,19 +685,23 @@ static int blob_content_to_file(
git_buf unfiltered = GIT_BUF_INIT, filtered = GIT_BUF_INIT; git_buf unfiltered = GIT_BUF_INIT, filtered = GIT_BUF_INIT;
git_vector filters = GIT_VECTOR_INIT; git_vector filters = GIT_VECTOR_INIT;
if (opts->disable_filters || /* Create a fake git_buf from the blob raw data... */
filtered.ptr = blob->odb_object->raw.data;
filtered.size = blob->odb_object->raw.len;
/* ... and make sure it doesn't get unexpectedly freed */
dont_free_filtered = true;
if (!opts->disable_filters &&
!git_buf_text_is_binary(&filtered) &&
(nb_filters = git_filters_load( (nb_filters = git_filters_load(
&filters, &filters,
git_object_owner((git_object *)blob), git_object_owner((git_object *)blob),
path, path,
GIT_FILTER_TO_WORKTREE)) == 0) { GIT_FILTER_TO_WORKTREE)) > 0)
{
/* Create a fake git_buf from the blob raw data... */ /* reset 'filtered' so it can be a filter target */
filtered.ptr = blob->odb_object->raw.data; git_buf_init(&filtered, 0);
filtered.size = blob->odb_object->raw.len; dont_free_filtered = false;
/* ... and make sure it doesn't get unexpectedly freed */
dont_free_filtered = true;
} }
if (nb_filters < 0) if (nb_filters < 0)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment