diff options
author | Edward Thomson <ethomson@github.com> | 2016-09-02 02:03:45 -0500 |
---|---|---|
committer | Edward Thomson <ethomson@github.com> | 2016-09-05 12:26:47 -0500 |
commit | adedac5aba9e4525475fd59d751cd02c6f2b3a4f (patch) | |
tree | 19fac5d44e30c3602909b9d971b26658545f2b7b /src/apply.c | |
parent | f4e3dae75ff7246952f6707ad2a2fdea758e03ea (diff) | |
download | libgit2-ethomson/diff-read-empty-binary.tar.gz |
diff: treat binary patches with no data specialethomson/diff-read-empty-binary
When creating and printing diffs, deal with binary deltas that have
binary data specially, versus diffs that have a binary file but lack the
actual binary data.
Diffstat (limited to 'src/apply.c')
-rw-r--r-- | src/apply.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/apply.c b/src/apply.c index 10bf1f492..f70172469 100644 --- a/src/apply.c +++ b/src/apply.c @@ -291,7 +291,15 @@ static int apply_binary( git_patch *patch) { git_buf reverse = GIT_BUF_INIT; - int error; + int error = 0; + + if (!patch->binary.contains_data) { + error = apply_err("patch does not contain binary data"); + goto done; + } + + if (!patch->binary.old_file.datalen && !patch->binary.new_file.datalen) + goto done; /* first, apply the new_file delta to the given source */ if ((error = apply_binary_delta(out, source, source_len, |