+ i = k;
+ goto again;
+ }
+
+ /* j is the first uninteresting line and there is
+ * no overlap beyond it within context lines. Paint
+ * the trailing edge a bit.
+ */
+ i = k;
+ k = (j + context < cnt+1) ? j + context : cnt+1;
+ while (j < k)
+ sline[j++].flag |= mark;
+ }
+ return 1;
+}
+
+static int make_hunks(struct sline *sline, unsigned long cnt,
+ int num_parent, int dense)
+{
+ unsigned long all_mask = (1UL<<num_parent) - 1;
+ unsigned long mark = (1UL<<num_parent);
+ unsigned long i;
+ int has_interesting = 0;
+
+ for (i = 0; i <= cnt; i++) {
+ if (interesting(&sline[i], all_mask))
+ sline[i].flag |= mark;
+ else
+ sline[i].flag &= ~mark;
+ }
+ if (!dense)
+ return give_context(sline, cnt, num_parent);
+
+ /* Look at each hunk, and if we have changes from only one
+ * parent, or the changes are the same from all but one
+ * parent, mark that uninteresting.
+ */
+ i = 0;
+ while (i <= cnt) {
+ unsigned long j, hunk_begin, hunk_end;
+ unsigned long same_diff;
+ while (i <= cnt && !(sline[i].flag & mark))
+ i++;
+ if (cnt < i)
+ break; /* No more interesting hunks */
+ hunk_begin = i;
+ for (j = i + 1; j <= cnt; j++) {
+ if (!(sline[j].flag & mark)) {
+ /* Look beyond the end to see if there
+ * is an interesting line after this
+ * hunk within context span.
+ */
+ unsigned long la; /* lookahead */
+ int contin = 0;
+ la = adjust_hunk_tail(sline, all_mask,
+ hunk_begin, j);
+ la = (la + context < cnt + 1) ?
+ (la + context) : cnt + 1;
+ while (j <= --la) {
+ if (sline[la].flag & mark) {
+ contin = 1;
+ break;
+ }
+ }
+ if (!contin)