summaryrefslogtreecommitdiff
path: root/src/diff_print.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-09-02 02:03:45 -0500
committerEdward Thomson <ethomson@github.com>2016-09-02 02:03:45 -0500
commit1cca150c71cfb0ac9dff0014b9d9b98aa9c3b691 (patch)
treeab3eec2b02c1ce3647c19ca9af0d8270a668bcfa /src/diff_print.c
parentd66e8c5f895d91e1dc1c72895cd0a90125756045 (diff)
downloadlibgit2-ethomson/diff-only-load-binaries-when-requested.tar.gz
diff: treat binary patches with no data specialethomson/diff-only-load-binaries-when-requested
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/diff_print.c')
-rw-r--r--src/diff_print.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/diff_print.c b/src/diff_print.c
index f72ca8935..c19693251 100644
--- a/src/diff_print.c
+++ b/src/diff_print.c
@@ -500,7 +500,6 @@ static int diff_print_patch_file_binary_noshow(
&new_path, new_pfx, delta->new_file.path)) < 0)
goto done;
-
pi->line.num_lines = 1;
error = diff_delta_format_with_paths(
pi->buf, delta, "Binary files %s and %s differ\n",
@@ -521,13 +520,10 @@ static int diff_print_patch_file_binary(
size_t pre_binary_size;
int error;
- if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0)
+ if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0 || binary->empty_data)
return diff_print_patch_file_binary_noshow(
pi, delta, old_pfx, new_pfx);
- if (binary->new_file.datalen == 0 && binary->old_file.datalen == 0)
- return 0;
-
pre_binary_size = pi->buf->size;
git_buf_printf(pi->buf, "GIT binary patch\n");
pi->line.num_lines++;
@@ -564,7 +560,8 @@ static int diff_print_patch_file(
(pi->flags & GIT_DIFF_FORCE_BINARY);
bool show_binary = !!(pi->flags & GIT_DIFF_SHOW_BINARY);
int id_strlen = binary && show_binary ?
- GIT_OID_HEXSZ : pi->id_strlen;
+ MAX(delta->old_file.id_abbrev, delta->new_file.id_abbrev) :
+ pi->id_strlen;
GIT_UNUSED(progress);