summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2013-01-10 15:59:36 -0800
committerPhilip Kelley <phkelley@hotmail.com>2013-01-11 17:26:34 -0500
commitad10db2af8d911d0b0913207ba919116375f09b4 (patch)
tree8938160ddfdd8abed56ffdd62b4375258c150723
parentfcc48d1fce2c456815b76501e1df07d02880d402 (diff)
downloadlibgit2-ad10db2af8d911d0b0913207ba919116375f09b4.tar.gz
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.
-rw-r--r--src/checkout.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/checkout.c b/src/checkout.c
index da22df680..98b7f6b9a 100644
--- a/src/checkout.c
+++ b/src/checkout.c
@@ -685,19 +685,23 @@ static int blob_content_to_file(
git_buf unfiltered = GIT_BUF_INIT, filtered = GIT_BUF_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(
&filters,
git_object_owner((git_object *)blob),
path,
- GIT_FILTER_TO_WORKTREE)) == 0) {
-
- /* 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;
+ GIT_FILTER_TO_WORKTREE)) > 0)
+ {
+ /* reset 'filtered' so it can be a filter target */
+ git_buf_init(&filtered, 0);
+ dont_free_filtered = false;
}
if (nb_filters < 0)