sync files from diff.git b72f51ffc39028023059fc994542565691b669fa This fixes a scrolling problem in tog's diff view for diffs which contain lines of the form "Binary files %s and %s differ".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
diff --git a/lib/diff_output_unidiff.c b/lib/diff_output_unidiff.c
index 5fc87f7..f3f4ad7 100644
--- a/lib/diff_output_unidiff.c
+++ b/lib/diff_output_unidiff.c
@@ -425,7 +425,8 @@ diff_output_unidiff(struct diff_output_info **output_info,
bool show_function_prototypes = (flags & DIFF_FLAG_SHOW_PROTOTYPES);
bool force_text = (flags & DIFF_FLAG_FORCE_TEXT_DATA);
bool have_binary = (atomizer_flags & DIFF_ATOMIZER_FOUND_BINARY_DATA);
- int i;
+ off_t outoff = 0, *offp;
+ int rc, i;
if (!result)
return EINVAL;
@@ -447,9 +448,23 @@ diff_output_unidiff(struct diff_output_info **output_info,
if (t != CHUNK_MINUS && t != CHUNK_PLUS)
continue;
- fprintf(dest, "Binary files %s and %s differ\n",
+ if (outinfo && outinfo->line_offsets.len > 0) {
+ unsigned int idx =
+ outinfo->line_offsets.len - 1;
+ outoff = outinfo->line_offsets.head[idx];
+ }
+
+ rc = fprintf(dest, "Binary files %s and %s differ\n",
diff_output_get_label_left(info),
diff_output_get_label_right(info));
+ if (outinfo) {
+ ARRAYLIST_ADD(offp, outinfo->line_offsets);
+ if (offp == NULL)
+ return ENOMEM;
+ outoff += rc;
+ *offp = outoff;
+
+ }
break;
}