7 #include "xdiff-interface.h"
10 static struct combine_diff_path *intersect_paths(struct combine_diff_path *curr, int n, int num_parent)
12 struct diff_queue_struct *q = &diff_queued_diff;
13 struct combine_diff_path *p;
17 struct combine_diff_path *list = NULL, **tail = &list;
18 for (i = 0; i < q->nr; i++) {
21 if (diff_unmodified_pair(q->queue[i]))
23 path = q->queue[i]->two->path;
25 p = xmalloc(combine_diff_path_size(num_parent, len));
26 p->path = (char*) &(p->parent[num_parent]);
27 memcpy(p->path, path, len);
32 sizeof(p->parent[0]) * num_parent);
34 hashcpy(p->sha1, q->queue[i]->two->sha1);
35 p->mode = q->queue[i]->two->mode;
36 hashcpy(p->parent[n].sha1, q->queue[i]->one->sha1);
37 p->parent[n].mode = q->queue[i]->one->mode;
38 p->parent[n].status = q->queue[i]->status;
45 for (p = curr; p; p = p->next) {
49 for (i = 0; i < q->nr; i++) {
53 if (diff_unmodified_pair(q->queue[i]))
55 path = q->queue[i]->two->path;
57 if (len == p->len && !memcmp(path, p->path, len)) {
59 hashcpy(p->parent[n].sha1, q->queue[i]->one->sha1);
60 p->parent[n].mode = q->queue[i]->one->mode;
61 p->parent[n].status = q->queue[i]->status;
71 /* Lines lost from parent */
75 unsigned long parent_map;
76 char line[FLEX_ARRAY];
79 /* Lines surviving in the merge result */
81 struct lline *lost_head, **lost_tail;
84 /* bit 0 up to (N-1) are on if the parent has this line (i.e.
85 * we did not change it).
86 * bit N is used for "interesting" lines, including context.
87 * bit (N+1) is used for "do not show deletion before this".
93 static char *grab_blob(const unsigned char *sha1, unsigned long *size)
96 enum object_type type;
97 if (is_null_sha1(sha1)) {
100 return xcalloc(1, 1);
102 blob = read_sha1_file(sha1, &type, size);
103 if (type != OBJ_BLOB)
104 die("object '%s' is not a blob!", sha1_to_hex(sha1));
108 static void append_lost(struct sline *sline, int n, const char *line, int len)
111 unsigned long this_mask = (1UL<<n);
112 if (line[len-1] == '\n')
115 /* Check to see if we can squash things */
116 if (sline->lost_head) {
117 struct lline *last_one = NULL;
118 /* We cannot squash it with earlier one */
119 for (lline = sline->lost_head;
122 if (lline->parent_map & this_mask)
124 lline = last_one ? last_one->next : sline->lost_head;
126 if (lline->len == len &&
127 !memcmp(lline->line, line, len)) {
128 lline->parent_map |= this_mask;
135 lline = xmalloc(sizeof(*lline) + len + 1);
138 lline->parent_map = this_mask;
139 memcpy(lline->line, line, len);
140 lline->line[len] = 0;
141 *sline->lost_tail = lline;
142 sline->lost_tail = &lline->next;
145 struct combine_diff_state {
146 struct xdiff_emit_state xm;
154 struct sline *lost_bucket;
157 static void consume_line(void *state_, char *line, unsigned long len)
159 struct combine_diff_state *state = state_;
160 if (5 < len && !memcmp("@@ -", line, 4)) {
161 if (parse_hunk_header(line, len,
162 &state->ob, &state->on,
163 &state->nb, &state->nn))
165 state->lno = state->nb;
167 /* @@ -1,2 +0,0 @@ to remove the
172 /* @@ -X,Y +N,0 @@ removed Y lines
173 * that would have come *after* line N
174 * in the result. Our lost buckets hang
175 * to the line after the removed lines,
177 state->lost_bucket = &state->sline[state->nb];
179 state->lost_bucket = &state->sline[state->nb-1];
180 if (!state->sline[state->nb-1].p_lno)
181 state->sline[state->nb-1].p_lno =
182 xcalloc(state->num_parent,
183 sizeof(unsigned long));
184 state->sline[state->nb-1].p_lno[state->n] = state->ob;
187 if (!state->lost_bucket)
188 return; /* not in any hunk yet */
191 append_lost(state->lost_bucket, state->n, line+1, len-1);
194 state->sline[state->lno-1].flag |= state->nmask;
200 static void combine_diff(const unsigned char *parent, mmfile_t *result_file,
201 struct sline *sline, unsigned int cnt, int n,
204 unsigned int p_lno, lno;
205 unsigned long nmask = (1UL << n);
208 mmfile_t parent_file;
210 struct combine_diff_state state;
214 return; /* result deleted */
216 parent_file.ptr = grab_blob(parent, &sz);
217 parent_file.size = sz;
218 xpp.flags = XDF_NEED_MINIMAL;
219 memset(&xecfg, 0, sizeof(xecfg));
220 ecb.outf = xdiff_outf;
222 memset(&state, 0, sizeof(state));
223 state.xm.consume = consume_line;
227 state.num_parent = num_parent;
230 xdi_diff(&parent_file, result_file, &xpp, &xecfg, &ecb);
231 free(parent_file.ptr);
233 /* Assign line numbers for this parent.
235 * sline[lno].p_lno[n] records the first line number
236 * (counting from 1) for parent N if the final hunk display
237 * started by showing sline[lno] (possibly showing the lost
238 * lines attached to it first).
240 for (lno = 0, p_lno = 1; lno <= cnt; lno++) {
242 sline[lno].p_lno[n] = p_lno;
244 /* How many lines would this sline advance the p_lno? */
245 ll = sline[lno].lost_head;
247 if (ll->parent_map & nmask)
248 p_lno++; /* '-' means parent had it */
251 if (lno < cnt && !(sline[lno].flag & nmask))
252 p_lno++; /* no '+' means parent had it */
254 sline[lno].p_lno[n] = p_lno; /* trailer */
257 static unsigned long context = 3;
258 static char combine_marker = '@';
260 static int interesting(struct sline *sline, unsigned long all_mask)
262 /* If some parents lost lines here, or if we have added to
263 * some parent, it is interesting.
265 return ((sline->flag & all_mask) || sline->lost_head);
268 static unsigned long adjust_hunk_tail(struct sline *sline,
269 unsigned long all_mask,
270 unsigned long hunk_begin,
273 /* i points at the first uninteresting line. If the last line
274 * of the hunk was interesting only because it has some
275 * deletion, then it is not all that interesting for the
276 * purpose of giving trailing context lines. This is because
277 * we output '-' line and then unmodified sline[i-1] itself in
278 * that case which gives us one extra context line.
280 if ((hunk_begin + 1 <= i) && !(sline[i-1].flag & all_mask))
285 static unsigned long find_next(struct sline *sline,
289 int look_for_uninteresting)
291 /* We have examined up to i-1 and are about to look at i.
292 * Find next interesting or uninteresting line. Here,
293 * "interesting" does not mean interesting(), but marked by
294 * the give_context() function below (i.e. it includes context
295 * lines that are not interesting to interesting() function
296 * that are surrounded by interesting() ones.
299 if (look_for_uninteresting
300 ? !(sline[i].flag & mark)
301 : (sline[i].flag & mark))
308 static int give_context(struct sline *sline, unsigned long cnt, int num_parent)
310 unsigned long all_mask = (1UL<<num_parent) - 1;
311 unsigned long mark = (1UL<<num_parent);
312 unsigned long no_pre_delete = (2UL<<num_parent);
315 /* Two groups of interesting lines may have a short gap of
316 * uninteresting lines. Connect such groups to give them a
319 * We first start from what the interesting() function says,
320 * and mark them with "mark", and paint context lines with the
321 * mark. So interesting() would still say false for such context
322 * lines but they are treated as "interesting" in the end.
324 i = find_next(sline, mark, 0, cnt, 0);
329 unsigned long j = (context < i) ? (i - context) : 0;
332 /* Paint a few lines before the first interesting line. */
334 sline[j++].flag |= mark | no_pre_delete;
337 /* we know up to i is to be included. where does the
338 * next uninteresting one start?
340 j = find_next(sline, mark, i, cnt, 1);
342 break; /* the rest are all interesting */
344 /* lookahead context lines */
345 k = find_next(sline, mark, j, cnt, 0);
346 j = adjust_hunk_tail(sline, all_mask, i, j);
348 if (k < j + context) {
349 /* k is interesting and [j,k) are not, but
350 * paint them interesting because the gap is small.
353 sline[j++].flag |= mark;
358 /* j is the first uninteresting line and there is
359 * no overlap beyond it within context lines. Paint
360 * the trailing edge a bit.
363 k = (j + context < cnt+1) ? j + context : cnt+1;
365 sline[j++].flag |= mark;
370 static int make_hunks(struct sline *sline, unsigned long cnt,
371 int num_parent, int dense)
373 unsigned long all_mask = (1UL<<num_parent) - 1;
374 unsigned long mark = (1UL<<num_parent);
376 int has_interesting = 0;
378 for (i = 0; i <= cnt; i++) {
379 if (interesting(&sline[i], all_mask))
380 sline[i].flag |= mark;
382 sline[i].flag &= ~mark;
385 return give_context(sline, cnt, num_parent);
387 /* Look at each hunk, and if we have changes from only one
388 * parent, or the changes are the same from all but one
389 * parent, mark that uninteresting.
393 unsigned long j, hunk_begin, hunk_end;
394 unsigned long same_diff;
395 while (i <= cnt && !(sline[i].flag & mark))
398 break; /* No more interesting hunks */
400 for (j = i + 1; j <= cnt; j++) {
401 if (!(sline[j].flag & mark)) {
402 /* Look beyond the end to see if there
403 * is an interesting line after this
404 * hunk within context span.
406 unsigned long la; /* lookahead */
408 la = adjust_hunk_tail(sline, all_mask,
410 la = (la + context < cnt + 1) ?
411 (la + context) : cnt + 1;
413 if (sline[la].flag & mark) {
425 /* [i..hunk_end) are interesting. Now is it really
426 * interesting? We check if there are only two versions
427 * and the result matches one of them. That is, we look
429 * (+) line, which records lines added to which parents;
430 * this line appears in the result.
431 * (-) line, which records from what parents the line
432 * was removed; this line does not appear in the result.
433 * then check the set of parents the result has difference
434 * from, from all lines. If there are lines that has
435 * different set of parents that the result has differences
436 * from, that means we have more than two versions.
438 * Even when we have only two versions, if the result does
439 * not match any of the parents, the it should be considered
440 * interesting. In such a case, we would have all '+' line.
441 * After passing the above "two versions" test, that would
442 * appear as "the same set of parents" to be "all parents".
446 for (j = i; j < hunk_end && !has_interesting; j++) {
447 unsigned long this_diff = sline[j].flag & all_mask;
448 struct lline *ll = sline[j].lost_head;
450 /* This has some changes. Is it the
454 same_diff = this_diff;
455 else if (same_diff != this_diff) {
460 while (ll && !has_interesting) {
461 /* Lost this line from these parents;
462 * who are they? Are they the same?
464 this_diff = ll->parent_map;
466 same_diff = this_diff;
467 else if (same_diff != this_diff) {
474 if (!has_interesting && same_diff != all_mask) {
475 /* This hunk is not that interesting after all */
476 for (j = hunk_begin; j < hunk_end; j++)
477 sline[j].flag &= ~mark;
482 has_interesting = give_context(sline, cnt, num_parent);
483 return has_interesting;
486 static void show_parent_lno(struct sline *sline, unsigned long l0, unsigned long l1, int n, unsigned long null_context)
488 l0 = sline[l0].p_lno[n];
489 l1 = sline[l1].p_lno[n];
490 printf(" -%lu,%lu", l0, l1-l0-null_context);
493 static int hunk_comment_line(const char *bol)
500 return (isalpha(ch) || ch == '_' || ch == '$');
503 static void dump_sline(struct sline *sline, unsigned long cnt, int num_parent,
506 unsigned long mark = (1UL<<num_parent);
507 unsigned long no_pre_delete = (2UL<<num_parent);
509 unsigned long lno = 0;
510 const char *c_frag = diff_get_color(use_color, DIFF_FRAGINFO);
511 const char *c_new = diff_get_color(use_color, DIFF_FILE_NEW);
512 const char *c_old = diff_get_color(use_color, DIFF_FILE_OLD);
513 const char *c_plain = diff_get_color(use_color, DIFF_PLAIN);
514 const char *c_reset = diff_get_color(use_color, DIFF_RESET);
517 return; /* result deleted */
520 struct sline *sl = &sline[lno];
521 unsigned long hunk_end;
522 unsigned long rlines;
523 const char *hunk_comment = NULL;
524 unsigned long null_context = 0;
526 while (lno <= cnt && !(sline[lno].flag & mark)) {
527 if (hunk_comment_line(sline[lno].bol))
528 hunk_comment = sline[lno].bol;
534 for (hunk_end = lno + 1; hunk_end <= cnt; hunk_end++)
535 if (!(sline[hunk_end].flag & mark))
538 rlines = hunk_end - lno;
540 rlines--; /* pointing at the last delete hunk */
544 * Even when running with --unified=0, all
545 * lines in the hunk needs to be processed in
546 * the loop below in order to show the
547 * deletion recorded in lost_head. However,
548 * we do not want to show the resulting line
549 * with all blank context markers in such a
553 for (j = lno; j < hunk_end; j++)
554 if (!(sline[j].flag & (mark-1)))
556 rlines -= null_context;
559 fputs(c_frag, stdout);
560 for (i = 0; i <= num_parent; i++) putchar(combine_marker);
561 for (i = 0; i < num_parent; i++)
562 show_parent_lno(sline, lno, hunk_end, i, null_context);
563 printf(" +%lu,%lu ", lno+1, rlines);
564 for (i = 0; i <= num_parent; i++) putchar(combine_marker);
568 for (i = 0; i < 40; i++) {
569 int ch = hunk_comment[i] & 0xff;
570 if (!ch || ch == '\n')
577 for (i = 0; i < comment_end; i++)
578 putchar(hunk_comment[i]);
581 printf("%s\n", c_reset);
582 while (lno < hunk_end) {
585 unsigned long p_mask;
587 ll = (sl->flag & no_pre_delete) ? NULL : sl->lost_head;
589 fputs(c_old, stdout);
590 for (j = 0; j < num_parent; j++) {
591 if (ll->parent_map & (1UL<<j))
596 printf("%s%s\n", ll->line, c_reset);
602 if (!(sl->flag & (mark-1))) {
604 * This sline was here to hang the
605 * lost lines in front of it.
609 fputs(c_plain, stdout);
612 fputs(c_new, stdout);
613 for (j = 0; j < num_parent; j++) {
614 if (p_mask & sl->flag)
620 printf("%.*s%s\n", sl->len, sl->bol, c_reset);
625 static void reuse_combine_diff(struct sline *sline, unsigned long cnt,
628 /* We have already examined parent j and we know parent i
629 * and parent j are the same, so reuse the combined result
630 * of parent j for parent i.
632 unsigned long lno, imask, jmask;
636 for (lno = 0; lno <= cnt; lno++) {
637 struct lline *ll = sline->lost_head;
638 sline->p_lno[i] = sline->p_lno[j];
640 if (ll->parent_map & jmask)
641 ll->parent_map |= imask;
644 if (sline->flag & jmask)
645 sline->flag |= imask;
648 /* the overall size of the file (sline[cnt]) */
649 sline->p_lno[i] = sline->p_lno[j];
652 static void dump_quoted_path(const char *head,
655 const char *c_meta, const char *c_reset)
657 static struct strbuf buf = STRBUF_INIT;
660 strbuf_addstr(&buf, c_meta);
661 strbuf_addstr(&buf, head);
662 quote_two_c_style(&buf, prefix, path, 0);
663 strbuf_addstr(&buf, c_reset);
667 static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
668 int dense, struct rev_info *rev)
670 struct diff_options *opt = &rev->diffopt;
671 unsigned long result_size, cnt, lno;
673 struct sline *sline; /* survived lines */
674 int mode_differs = 0;
676 int working_tree_file = is_null_sha1(elem->sha1);
677 int abbrev = DIFF_OPT_TST(opt, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
678 mmfile_t result_file;
680 context = opt->context;
681 /* Read the result of merge first */
682 if (!working_tree_file)
683 result = grab_blob(elem->sha1, &result_size);
685 /* Used by diff-tree to read from the working tree */
689 if (lstat(elem->path, &st) < 0)
692 if (S_ISLNK(st.st_mode)) {
693 size_t len = xsize_t(st.st_size);
695 result = xmalloc(len + 1);
696 if (result_size != readlink(elem->path, result, len)) {
697 error("readlink(%s): %s", elem->path,
702 elem->mode = canon_mode(st.st_mode);
704 else if (0 <= (fd = open(elem->path, O_RDONLY)) &&
706 size_t len = xsize_t(st.st_size);
710 elem->mode = canon_mode(st.st_mode);
711 /* if symlinks don't work, assume symlink if all parents
714 is_file = has_symlinks;
715 for (i = 0; !is_file && i < num_parent; i++)
716 is_file = !S_ISLNK(elem->parent[i].mode);
718 elem->mode = canon_mode(S_IFLNK);
721 result = xmalloc(len + 1);
723 done = read_in_full(fd, result, len);
725 die("read error '%s'", elem->path);
727 die("early EOF '%s'", elem->path);
735 result = xcalloc(1, 1);
742 for (cnt = 0, cp = result; cp < result + result_size; cp++) {
746 if (result_size && result[result_size-1] != '\n')
747 cnt++; /* incomplete line */
749 sline = xcalloc(cnt+2, sizeof(*sline));
750 sline[0].bol = result;
751 for (lno = 0; lno <= cnt + 1; lno++) {
752 sline[lno].lost_tail = &sline[lno].lost_head;
755 for (lno = 0, cp = result; cp < result + result_size; cp++) {
757 sline[lno].len = cp - sline[lno].bol;
760 sline[lno].bol = cp + 1;
763 if (result_size && result[result_size-1] != '\n')
764 sline[cnt-1].len = result_size - (sline[cnt-1].bol - result);
766 result_file.ptr = result;
767 result_file.size = result_size;
769 /* Even p_lno[cnt+1] is valid -- that is for the end line number
770 * for deletion hunk at the end.
772 sline[0].p_lno = xcalloc((cnt+2) * num_parent, sizeof(unsigned long));
773 for (lno = 0; lno <= cnt; lno++)
774 sline[lno+1].p_lno = sline[lno].p_lno + num_parent;
776 for (i = 0; i < num_parent; i++) {
778 for (j = 0; j < i; j++) {
779 if (!hashcmp(elem->parent[i].sha1,
780 elem->parent[j].sha1)) {
781 reuse_combine_diff(sline, cnt, i, j);
786 combine_diff(elem->parent[i].sha1, &result_file, sline,
788 if (elem->parent[i].mode != elem->mode)
792 show_hunks = make_hunks(sline, cnt, num_parent, dense);
794 if (show_hunks || mode_differs || working_tree_file) {
796 int use_color = DIFF_OPT_TST(opt, COLOR_DIFF);
797 const char *c_meta = diff_get_color(use_color, DIFF_METAINFO);
798 const char *c_reset = diff_get_color(use_color, DIFF_RESET);
802 if (rev->loginfo && !rev->no_commit_id)
804 dump_quoted_path(dense ? "diff --cc " : "diff --combined ",
805 "", elem->path, c_meta, c_reset);
806 printf("%sindex ", c_meta);
807 for (i = 0; i < num_parent; i++) {
808 abb = find_unique_abbrev(elem->parent[i].sha1,
810 printf("%s%s", i ? "," : "", abb);
812 abb = find_unique_abbrev(elem->sha1, abbrev);
813 printf("..%s%s\n", abb, c_reset);
816 deleted = !elem->mode;
818 /* We say it was added if nobody had it */
820 for (i = 0; added && i < num_parent; i++)
821 if (elem->parent[i].status !=
825 printf("%snew file mode %06o",
829 printf("%sdeleted file ", c_meta);
831 for (i = 0; i < num_parent; i++) {
832 printf("%s%06o", i ? "," : "",
833 elem->parent[i].mode);
836 printf("..%06o", elem->mode);
838 printf("%s\n", c_reset);
841 dump_quoted_path("--- ", "", "/dev/null",
844 dump_quoted_path("--- ", opt->a_prefix, elem->path,
847 dump_quoted_path("+++ ", "", "/dev/null",
850 dump_quoted_path("+++ ", opt->b_prefix, elem->path,
852 dump_sline(sline, cnt, num_parent,
853 DIFF_OPT_TST(opt, COLOR_DIFF));
857 for (lno = 0; lno < cnt; lno++) {
858 if (sline[lno].lost_head) {
859 struct lline *ll = sline[lno].lost_head;
861 struct lline *tmp = ll;
867 free(sline[0].p_lno);
871 #define COLONS "::::::::::::::::::::::::::::::::"
873 static void show_raw_diff(struct combine_diff_path *p, int num_parent, struct rev_info *rev)
875 struct diff_options *opt = &rev->diffopt;
878 int line_termination, inter_name_termination;
880 line_termination = opt->line_termination;
881 inter_name_termination = '\t';
882 if (!line_termination)
883 inter_name_termination = 0;
885 if (rev->loginfo && !rev->no_commit_id)
888 if (opt->output_format & DIFF_FORMAT_RAW) {
889 offset = strlen(COLONS) - num_parent;
892 prefix = COLONS + offset;
895 for (i = 0; i < num_parent; i++) {
896 printf("%s%06o", prefix, p->parent[i].mode);
899 printf("%s%06o", prefix, p->mode);
902 for (i = 0; i < num_parent; i++)
903 printf(" %s", diff_unique_abbrev(p->parent[i].sha1,
905 printf(" %s ", diff_unique_abbrev(p->sha1, opt->abbrev));
908 if (opt->output_format & (DIFF_FORMAT_RAW | DIFF_FORMAT_NAME_STATUS)) {
909 for (i = 0; i < num_parent; i++)
910 putchar(p->parent[i].status);
911 putchar(inter_name_termination);
914 write_name_quoted(p->path, stdout, line_termination);
917 void show_combined_diff(struct combine_diff_path *p,
920 struct rev_info *rev)
922 struct diff_options *opt = &rev->diffopt;
925 if (opt->output_format & (DIFF_FORMAT_RAW |
927 DIFF_FORMAT_NAME_STATUS))
928 show_raw_diff(p, num_parent, rev);
929 else if (opt->output_format & DIFF_FORMAT_PATCH)
930 show_patch_diff(p, num_parent, dense, rev);
933 void diff_tree_combined(const unsigned char *sha1,
934 const unsigned char parent[][20],
937 struct rev_info *rev)
939 struct diff_options *opt = &rev->diffopt;
940 struct diff_options diffopts;
941 struct combine_diff_path *p, *paths = NULL;
942 int i, num_paths, needsep, show_log_first;
945 diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
946 DIFF_OPT_SET(&diffopts, RECURSIVE);
947 DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
949 show_log_first = !!rev->loginfo && !rev->no_commit_id;
951 /* find set of paths that everybody touches */
952 for (i = 0; i < num_parent; i++) {
953 /* show stat against the first parent even
954 * when doing combined diff.
956 int stat_opt = (opt->output_format &
957 (DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT));
958 if (i == 0 && stat_opt)
959 diffopts.output_format = stat_opt;
961 diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
962 diff_tree_sha1(parent[i], sha1, "", &diffopts);
963 diffcore_std(&diffopts);
964 paths = intersect_paths(paths, i, num_parent);
966 if (show_log_first && i == 0) {
968 if (rev->verbose_header && opt->output_format)
969 putchar(opt->line_termination);
971 diff_flush(&diffopts);
974 /* find out surviving paths */
975 for (num_paths = 0, p = paths; p; p = p->next) {
980 if (opt->output_format & (DIFF_FORMAT_RAW |
982 DIFF_FORMAT_NAME_STATUS)) {
983 for (p = paths; p; p = p->next) {
985 show_raw_diff(p, num_parent, rev);
989 else if (opt->output_format &
990 (DIFF_FORMAT_NUMSTAT|DIFF_FORMAT_DIFFSTAT))
992 if (opt->output_format & DIFF_FORMAT_PATCH) {
994 putchar(opt->line_termination);
995 for (p = paths; p; p = p->next) {
997 show_patch_diff(p, num_parent, dense,
1003 /* Clean things up */
1005 struct combine_diff_path *tmp = paths;
1006 paths = paths->next;
1011 void diff_tree_combined_merge(const unsigned char *sha1,
1012 int dense, struct rev_info *rev)
1015 const unsigned char (*parent)[20];
1016 struct commit *commit = lookup_commit(sha1);
1017 struct commit_list *parents;
1020 for (parents = commit->parents, num_parent = 0;
1022 parents = parents->next, num_parent++)
1025 parent = xmalloc(num_parent * sizeof(*parent));
1026 for (parents = commit->parents, num_parent = 0;
1028 parents = parents->next, num_parent++)
1029 hashcpy((unsigned char*)(parent + num_parent),
1030 parents->item->object.sha1);
1031 diff_tree_combined(sha1, parent, num_parent, dense, rev);