summaryrefslogtreecommitdiff
path: root/src/diff_print.c
diff options
context:
space:
mode:
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);