summaryrefslogtreecommitdiff
path: root/src/diff_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diff_file.c')
-rw-r--r--src/diff_file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/diff_file.c b/src/diff_file.c
index 270d59bbb..0813315f5 100644
--- a/src/diff_file.c
+++ b/src/diff_file.c
@@ -139,7 +139,6 @@ int git_diff_file_content__init_from_src(
memset(fc, 0, sizeof(*fc));
fc->repo = repo;
fc->file = as_file;
- fc->blob = src->blob;
if (!src->blob && !src->buf) {
fc->flags |= GIT_DIFF_FLAG__NO_DATA;
@@ -149,12 +148,15 @@ int git_diff_file_content__init_from_src(
fc->file->mode = GIT_FILEMODE_BLOB;
if (src->blob) {
+ git_blob_dup((git_blob **)&fc->blob, (git_blob *) src->blob);
fc->file->size = git_blob_rawsize(src->blob);
git_oid_cpy(&fc->file->id, git_blob_id(src->blob));
fc->file->id_abbrev = GIT_OID_HEXSZ;
fc->map.len = (size_t)fc->file->size;
fc->map.data = (char *)git_blob_rawcontent(src->blob);
+
+ fc->flags |= GIT_DIFF_FLAG__FREE_BLOB;
} else {
fc->file->size = src->buflen;
git_odb_hash(&fc->file->id, src->buf, src->buflen, GIT_OBJ_BLOB);