vendor/libgit2/src/diff_print.c in rugged-0.25.0b8 vs vendor/libgit2/src/diff_print.c in rugged-0.25.0b9

- old
+ new

@@ -498,11 +498,10 @@ &old_path, old_pfx, delta->old_file.path)) < 0 || (error = diff_delta_format_path( &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", old_path.ptr, new_path.ptr); @@ -519,17 +518,17 @@ const git_diff_binary *binary) { size_t pre_binary_size; int error; - if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0) + if (delta->status == GIT_DELTA_UNMODIFIED) + return 0; + + if ((pi->flags & GIT_DIFF_SHOW_BINARY) == 0 || !binary->contains_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++; if ((error = format_binary(pi, binary->new_file.type, binary->new_file.data, @@ -561,11 +560,14 @@ pi->new_prefix ? pi->new_prefix : DIFF_NEW_PREFIX_DEFAULT; bool binary = (delta->flags & GIT_DIFF_FLAG_BINARY) || (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; + int id_strlen = pi->id_strlen; + + if (binary && show_binary) + id_strlen = delta->old_file.id_abbrev ? delta->old_file.id_abbrev : + delta->new_file.id_abbrev; GIT_UNUSED(progress); if (S_ISDIR(delta->new_file.mode) || delta->status == GIT_DELTA_UNMODIFIED ||