7 #include "xdiff-interface.h"
10 static int uninteresting(struct diff_filepair
*p
)
12 if (diff_unmodified_pair(p
))
17 static struct combine_diff_path
*intersect_paths(struct combine_diff_path
*curr
, int n
, int num_parent
)
19 struct diff_queue_struct
*q
= &diff_queued_diff
;
20 struct combine_diff_path
*p
;
24 struct combine_diff_path
*list
= NULL
, **tail
= &list
;
25 for (i
= 0; i
< q
->nr
; i
++) {
28 if (uninteresting(q
->queue
[i
]))
30 path
= q
->queue
[i
]->two
->path
;
32 p
= xmalloc(combine_diff_path_size(num_parent
, len
));
33 p
->path
= (char*) &(p
->parent
[num_parent
]);
34 memcpy(p
->path
, path
, len
);
39 sizeof(p
->parent
[0]) * num_parent
);
41 memcpy(p
->sha1
, q
->queue
[i
]->two
->sha1
, 20);
42 p
->mode
= q
->queue
[i
]->two
->mode
;
43 memcpy(p
->parent
[n
].sha1
, q
->queue
[i
]->one
->sha1
, 20);
44 p
->parent
[n
].mode
= q
->queue
[i
]->one
->mode
;
45 p
->parent
[n
].status
= q
->queue
[i
]->status
;
52 for (p
= curr
; p
; p
= p
->next
) {
56 for (i
= 0; i
< q
->nr
; i
++) {
60 if (uninteresting(q
->queue
[i
]))
62 path
= q
->queue
[i
]->two
->path
;
64 if (len
== p
->len
&& !memcmp(path
, p
->path
, len
)) {
66 memcpy(p
->parent
[n
].sha1
,
67 q
->queue
[i
]->one
->sha1
, 20);
68 p
->parent
[n
].mode
= q
->queue
[i
]->one
->mode
;
69 p
->parent
[n
].status
= q
->queue
[i
]->status
;
79 /* Lines lost from parent */
83 unsigned long parent_map
;
84 char line
[FLEX_ARRAY
];
87 /* Lines surviving in the merge result */
89 struct lline
*lost_head
, **lost_tail
;
92 /* bit 0 up to (N-1) are on if the parent has this line (i.e.
93 * we did not change it).
94 * bit N is used for "interesting" lines, including context.
100 static char *grab_blob(const unsigned char *sha1
, unsigned long *size
)
104 if (!memcmp(sha1
, null_sha1
, 20)) {
107 return xcalloc(1, 1);
109 blob
= read_sha1_file(sha1
, type
, size
);
110 if (strcmp(type
, blob_type
))
111 die("object '%s' is not a blob!", sha1_to_hex(sha1
));
115 static void append_lost(struct sline
*sline
, int n
, const char *line
, int len
)
118 unsigned long this_mask
= (1UL<<n
);
119 if (line
[len
-1] == '\n')
122 /* Check to see if we can squash things */
123 if (sline
->lost_head
) {
124 struct lline
*last_one
= NULL
;
125 /* We cannot squash it with earlier one */
126 for (lline
= sline
->lost_head
;
129 if (lline
->parent_map
& this_mask
)
131 lline
= last_one
? last_one
->next
: sline
->lost_head
;
133 if (lline
->len
== len
&&
134 !memcmp(lline
->line
, line
, len
)) {
135 lline
->parent_map
|= this_mask
;
142 lline
= xmalloc(sizeof(*lline
) + len
+ 1);
145 lline
->parent_map
= this_mask
;
146 memcpy(lline
->line
, line
, len
);
147 lline
->line
[len
] = 0;
148 *sline
->lost_tail
= lline
;
149 sline
->lost_tail
= &lline
->next
;
152 struct combine_diff_state
{
153 struct xdiff_emit_state xm
;
161 struct sline
*lost_bucket
;
164 static void consume_line(void *state_
, char *line
, unsigned long len
)
166 struct combine_diff_state
*state
= state_
;
167 if (5 < len
&& !memcmp("@@ -", line
, 4)) {
168 if (parse_hunk_header(line
, len
,
169 &state
->ob
, &state
->on
,
170 &state
->nb
, &state
->nn
))
172 state
->lno
= state
->nb
;
174 /* @@ -1,2 +0,0 @@ to remove the
179 /* @@ -X,Y +N,0 @@ removed Y lines
180 * that would have come *after* line N
181 * in the result. Our lost buckets hang
182 * to the line after the removed lines,
184 state
->lost_bucket
= &state
->sline
[state
->nb
];
186 state
->lost_bucket
= &state
->sline
[state
->nb
-1];
187 if (!state
->sline
[state
->nb
-1].p_lno
)
188 state
->sline
[state
->nb
-1].p_lno
=
189 xcalloc(state
->num_parent
,
190 sizeof(unsigned long));
191 state
->sline
[state
->nb
-1].p_lno
[state
->n
] = state
->ob
;
194 if (!state
->lost_bucket
)
195 return; /* not in any hunk yet */
198 append_lost(state
->lost_bucket
, state
->n
, line
+1, len
-1);
201 state
->sline
[state
->lno
-1].flag
|= state
->nmask
;
207 static void combine_diff(const unsigned char *parent
, mmfile_t
*result_file
,
208 struct sline
*sline
, unsigned int cnt
, int n
,
211 unsigned int p_lno
, lno
;
212 unsigned long nmask
= (1UL << n
);
215 mmfile_t parent_file
;
217 struct combine_diff_state state
;
221 return; /* result deleted */
223 parent_file
.ptr
= grab_blob(parent
, &sz
);
224 parent_file
.size
= sz
;
225 xpp
.flags
= XDF_NEED_MINIMAL
;
228 ecb
.outf
= xdiff_outf
;
230 memset(&state
, 0, sizeof(state
));
231 state
.xm
.consume
= consume_line
;
235 state
.num_parent
= num_parent
;
238 xdl_diff(&parent_file
, result_file
, &xpp
, &xecfg
, &ecb
);
239 free(parent_file
.ptr
);
241 /* Assign line numbers for this parent.
243 * sline[lno].p_lno[n] records the first line number
244 * (counting from 1) for parent N if the final hunk display
245 * started by showing sline[lno] (possibly showing the lost
246 * lines attached to it first).
248 for (lno
= 0, p_lno
= 1; lno
<= cnt
; lno
++) {
250 sline
[lno
].p_lno
[n
] = p_lno
;
252 /* How many lines would this sline advance the p_lno? */
253 ll
= sline
[lno
].lost_head
;
255 if (ll
->parent_map
& nmask
)
256 p_lno
++; /* '-' means parent had it */
259 if (lno
< cnt
&& !(sline
[lno
].flag
& nmask
))
260 p_lno
++; /* no '+' means parent had it */
262 sline
[lno
].p_lno
[n
] = p_lno
; /* trailer */
265 static unsigned long context
= 3;
266 static char combine_marker
= '@';
268 static int interesting(struct sline
*sline
, unsigned long all_mask
)
270 /* If some parents lost lines here, or if we have added to
271 * some parent, it is interesting.
273 return ((sline
->flag
& all_mask
) || sline
->lost_head
);
276 static unsigned long adjust_hunk_tail(struct sline
*sline
,
277 unsigned long all_mask
,
278 unsigned long hunk_begin
,
281 /* i points at the first uninteresting line. If the last line
282 * of the hunk was interesting only because it has some
283 * deletion, then it is not all that interesting for the
284 * purpose of giving trailing context lines. This is because
285 * we output '-' line and then unmodified sline[i-1] itself in
286 * that case which gives us one extra context line.
288 if ((hunk_begin
+ 1 <= i
) && !(sline
[i
-1].flag
& all_mask
))
293 static unsigned long find_next(struct sline
*sline
,
297 int look_for_uninteresting
)
299 /* We have examined up to i-1 and are about to look at i.
300 * Find next interesting or uninteresting line. Here,
301 * "interesting" does not mean interesting(), but marked by
302 * the give_context() function below (i.e. it includes context
303 * lines that are not interesting to interesting() function
304 * that are surrounded by interesting() ones.
307 if (look_for_uninteresting
308 ? !(sline
[i
].flag
& mark
)
309 : (sline
[i
].flag
& mark
))
316 static int give_context(struct sline
*sline
, unsigned long cnt
, int num_parent
)
318 unsigned long all_mask
= (1UL<<num_parent
) - 1;
319 unsigned long mark
= (1UL<<num_parent
);
322 /* Two groups of interesting lines may have a short gap of
323 * uninteresting lines. Connect such groups to give them a
326 * We first start from what the interesting() function says,
327 * and mark them with "mark", and paint context lines with the
328 * mark. So interesting() would still say false for such context
329 * lines but they are treated as "interesting" in the end.
331 i
= find_next(sline
, mark
, 0, cnt
, 0);
336 unsigned long j
= (context
< i
) ? (i
- context
) : 0;
339 /* Paint a few lines before the first interesting line. */
341 sline
[j
++].flag
|= mark
;
344 /* we know up to i is to be included. where does the
345 * next uninteresting one start?
347 j
= find_next(sline
, mark
, i
, cnt
, 1);
349 break; /* the rest are all interesting */
351 /* lookahead context lines */
352 k
= find_next(sline
, mark
, j
, cnt
, 0);
353 j
= adjust_hunk_tail(sline
, all_mask
, i
, j
);
355 if (k
< j
+ context
) {
356 /* k is interesting and [j,k) are not, but
357 * paint them interesting because the gap is small.
360 sline
[j
++].flag
|= mark
;
365 /* j is the first uninteresting line and there is
366 * no overlap beyond it within context lines. Paint
367 * the trailing edge a bit.
370 k
= (j
+ context
< cnt
+1) ? j
+ context
: cnt
+1;
372 sline
[j
++].flag
|= mark
;
377 static int make_hunks(struct sline
*sline
, unsigned long cnt
,
378 int num_parent
, int dense
)
380 unsigned long all_mask
= (1UL<<num_parent
) - 1;
381 unsigned long mark
= (1UL<<num_parent
);
383 int has_interesting
= 0;
385 for (i
= 0; i
<= cnt
; i
++) {
386 if (interesting(&sline
[i
], all_mask
))
387 sline
[i
].flag
|= mark
;
389 sline
[i
].flag
&= ~mark
;
392 return give_context(sline
, cnt
, num_parent
);
394 /* Look at each hunk, and if we have changes from only one
395 * parent, or the changes are the same from all but one
396 * parent, mark that uninteresting.
400 unsigned long j
, hunk_begin
, hunk_end
;
401 unsigned long same_diff
;
402 while (i
<= cnt
&& !(sline
[i
].flag
& mark
))
405 break; /* No more interesting hunks */
407 for (j
= i
+ 1; j
<= cnt
; j
++) {
408 if (!(sline
[j
].flag
& mark
)) {
409 /* Look beyond the end to see if there
410 * is an interesting line after this
411 * hunk within context span.
413 unsigned long la
; /* lookahead */
415 la
= adjust_hunk_tail(sline
, all_mask
,
417 la
= (la
+ context
< cnt
+ 1) ?
418 (la
+ context
) : cnt
+ 1;
420 if (sline
[la
].flag
& mark
) {
432 /* [i..hunk_end) are interesting. Now is it really
433 * interesting? We check if there are only two versions
434 * and the result matches one of them. That is, we look
436 * (+) line, which records lines added to which parents;
437 * this line appears in the result.
438 * (-) line, which records from what parents the line
439 * was removed; this line does not appear in the result.
440 * then check the set of parents the result has difference
441 * from, from all lines. If there are lines that has
442 * different set of parents that the result has differences
443 * from, that means we have more than two versions.
445 * Even when we have only two versions, if the result does
446 * not match any of the parents, the it should be considered
447 * interesting. In such a case, we would have all '+' line.
448 * After passing the above "two versions" test, that would
449 * appear as "the same set of parents" to be "all parents".
453 for (j
= i
; j
< hunk_end
&& !has_interesting
; j
++) {
454 unsigned long this_diff
= sline
[j
].flag
& all_mask
;
455 struct lline
*ll
= sline
[j
].lost_head
;
457 /* This has some changes. Is it the
461 same_diff
= this_diff
;
462 else if (same_diff
!= this_diff
) {
467 while (ll
&& !has_interesting
) {
468 /* Lost this line from these parents;
469 * who are they? Are they the same?
471 this_diff
= ll
->parent_map
;
473 same_diff
= this_diff
;
474 else if (same_diff
!= this_diff
) {
481 if (!has_interesting
&& same_diff
!= all_mask
) {
482 /* This hunk is not that interesting after all */
483 for (j
= hunk_begin
; j
< hunk_end
; j
++)
484 sline
[j
].flag
&= ~mark
;
489 has_interesting
= give_context(sline
, cnt
, num_parent
);
490 return has_interesting
;
493 static void show_parent_lno(struct sline
*sline
, unsigned long l0
, unsigned long l1
, int n
)
495 l0
= sline
[l0
].p_lno
[n
];
496 l1
= sline
[l1
].p_lno
[n
];
497 printf(" -%lu,%lu", l0
, l1
-l0
);
500 static void dump_sline(struct sline
*sline
, unsigned long cnt
, int num_parent
,
503 unsigned long mark
= (1UL<<num_parent
);
505 unsigned long lno
= 0;
506 const char *c_frag
= diff_get_color(use_color
, DIFF_FRAGINFO
);
507 const char *c_new
= diff_get_color(use_color
, DIFF_FILE_NEW
);
508 const char *c_old
= diff_get_color(use_color
, DIFF_FILE_OLD
);
509 const char *c_plain
= diff_get_color(use_color
, DIFF_PLAIN
);
510 const char *c_reset
= diff_get_color(use_color
, DIFF_RESET
);
513 return; /* result deleted */
516 struct sline
*sl
= &sline
[lno
];
517 unsigned long hunk_end
;
518 unsigned long rlines
;
519 while (lno
<= cnt
&& !(sline
[lno
].flag
& mark
))
524 for (hunk_end
= lno
+ 1; hunk_end
<= cnt
; hunk_end
++)
525 if (!(sline
[hunk_end
].flag
& mark
))
528 rlines
= hunk_end
- lno
;
530 rlines
--; /* pointing at the last delete hunk */
531 fputs(c_frag
, stdout
);
532 for (i
= 0; i
<= num_parent
; i
++) putchar(combine_marker
);
533 for (i
= 0; i
< num_parent
; i
++)
534 show_parent_lno(sline
, lno
, hunk_end
, i
);
535 printf(" +%lu,%lu ", lno
+1, rlines
);
536 for (i
= 0; i
<= num_parent
; i
++) putchar(combine_marker
);
537 printf("%s\n", c_reset
);
538 while (lno
< hunk_end
) {
541 unsigned long p_mask
;
545 fputs(c_old
, stdout
);
546 for (j
= 0; j
< num_parent
; j
++) {
547 if (ll
->parent_map
& (1UL<<j
))
552 printf("%s%s\n", ll
->line
, c_reset
);
558 if (!(sl
->flag
& (mark
-1)))
559 fputs(c_plain
, stdout
);
561 fputs(c_new
, stdout
);
562 for (j
= 0; j
< num_parent
; j
++) {
563 if (p_mask
& sl
->flag
)
569 printf("%.*s%s\n", sl
->len
, sl
->bol
, c_reset
);
574 static void reuse_combine_diff(struct sline
*sline
, unsigned long cnt
,
577 /* We have already examined parent j and we know parent i
578 * and parent j are the same, so reuse the combined result
579 * of parent j for parent i.
581 unsigned long lno
, imask
, jmask
;
585 for (lno
= 0; lno
<= cnt
; lno
++) {
586 struct lline
*ll
= sline
->lost_head
;
587 sline
->p_lno
[i
] = sline
->p_lno
[j
];
589 if (ll
->parent_map
& jmask
)
590 ll
->parent_map
|= imask
;
593 if (sline
->flag
& jmask
)
594 sline
->flag
|= imask
;
597 /* the overall size of the file (sline[cnt]) */
598 sline
->p_lno
[i
] = sline
->p_lno
[j
];
601 static void dump_quoted_path(const char *prefix
, const char *path
,
602 const char *c_meta
, const char *c_reset
)
604 printf("%s%s", c_meta
, prefix
);
605 if (quote_c_style(path
, NULL
, NULL
, 0))
606 quote_c_style(path
, NULL
, stdout
, 0);
609 printf("%s\n", c_reset
);
612 static void show_patch_diff(struct combine_diff_path
*elem
, int num_parent
,
613 int dense
, struct rev_info
*rev
)
615 struct diff_options
*opt
= &rev
->diffopt
;
616 unsigned long result_size
, cnt
, lno
;
618 struct sline
*sline
; /* survived lines */
619 int mode_differs
= 0;
621 int working_tree_file
= !memcmp(elem
->sha1
, null_sha1
, 20);
622 int abbrev
= opt
->full_index
? 40 : DEFAULT_ABBREV
;
623 mmfile_t result_file
;
625 context
= opt
->context
;
626 /* Read the result of merge first */
627 if (!working_tree_file
)
628 result
= grab_blob(elem
->sha1
, &result_size
);
630 /* Used by diff-tree to read from the working tree */
633 if (0 <= (fd
= open(elem
->path
, O_RDONLY
)) &&
635 int len
= st
.st_size
;
638 elem
->mode
= canon_mode(st
.st_mode
);
640 result
= xmalloc(len
+ 1);
642 int done
= xread(fd
, result
+sz
, len
-sz
);
646 die("read error '%s'", elem
->path
);
655 result
= xcalloc(1, 1);
661 for (cnt
= 0, cp
= result
; cp
< result
+ result_size
; cp
++) {
665 if (result_size
&& result
[result_size
-1] != '\n')
666 cnt
++; /* incomplete line */
668 sline
= xcalloc(cnt
+2, sizeof(*sline
));
669 sline
[0].bol
= result
;
670 for (lno
= 0; lno
<= cnt
+ 1; lno
++) {
671 sline
[lno
].lost_tail
= &sline
[lno
].lost_head
;
674 for (lno
= 0, cp
= result
; cp
< result
+ result_size
; cp
++) {
676 sline
[lno
].len
= cp
- sline
[lno
].bol
;
679 sline
[lno
].bol
= cp
+ 1;
682 if (result_size
&& result
[result_size
-1] != '\n')
683 sline
[cnt
-1].len
= result_size
- (sline
[cnt
-1].bol
- result
);
685 result_file
.ptr
= result
;
686 result_file
.size
= result_size
;
688 /* Even p_lno[cnt+1] is valid -- that is for the end line number
689 * for deletion hunk at the end.
691 sline
[0].p_lno
= xcalloc((cnt
+2) * num_parent
, sizeof(unsigned long));
692 for (lno
= 0; lno
<= cnt
; lno
++)
693 sline
[lno
+1].p_lno
= sline
[lno
].p_lno
+ num_parent
;
695 for (i
= 0; i
< num_parent
; i
++) {
697 for (j
= 0; j
< i
; j
++) {
698 if (!memcmp(elem
->parent
[i
].sha1
,
699 elem
->parent
[j
].sha1
, 20)) {
700 reuse_combine_diff(sline
, cnt
, i
, j
);
705 combine_diff(elem
->parent
[i
].sha1
, &result_file
, sline
,
707 if (elem
->parent
[i
].mode
!= elem
->mode
)
711 show_hunks
= make_hunks(sline
, cnt
, num_parent
, dense
);
713 if (show_hunks
|| mode_differs
|| working_tree_file
) {
715 int use_color
= opt
->color_diff
;
716 const char *c_meta
= diff_get_color(use_color
, DIFF_METAINFO
);
717 const char *c_reset
= diff_get_color(use_color
, DIFF_RESET
);
720 show_log(rev
, opt
->msg_sep
);
721 dump_quoted_path(dense
? "diff --cc " : "diff --combined ",
722 elem
->path
, c_meta
, c_reset
);
723 printf("%sindex ", c_meta
);
724 for (i
= 0; i
< num_parent
; i
++) {
725 abb
= find_unique_abbrev(elem
->parent
[i
].sha1
,
727 printf("%s%s", i
? "," : "", abb
);
729 abb
= find_unique_abbrev(elem
->sha1
, abbrev
);
730 printf("..%s%s\n", abb
, c_reset
);
733 int added
= !!elem
->mode
;
734 for (i
= 0; added
&& i
< num_parent
; i
++)
735 if (elem
->parent
[i
].status
!=
739 printf("%snew file mode %06o",
743 printf("%sdeleted file ", c_meta
);
745 for (i
= 0; i
< num_parent
; i
++) {
746 printf("%s%06o", i
? "," : "",
747 elem
->parent
[i
].mode
);
750 printf("..%06o", elem
->mode
);
752 printf("%s\n", c_reset
);
754 dump_quoted_path("--- a/", elem
->path
, c_meta
, c_reset
);
755 dump_quoted_path("+++ b/", elem
->path
, c_meta
, c_reset
);
756 dump_sline(sline
, cnt
, num_parent
, opt
->color_diff
);
760 for (lno
= 0; lno
< cnt
; lno
++) {
761 if (sline
[lno
].lost_head
) {
762 struct lline
*ll
= sline
[lno
].lost_head
;
764 struct lline
*tmp
= ll
;
770 free(sline
[0].p_lno
);
774 #define COLONS "::::::::::::::::::::::::::::::::"
776 static void show_raw_diff(struct combine_diff_path
*p
, int num_parent
, struct rev_info
*rev
)
778 struct diff_options
*opt
= &rev
->diffopt
;
781 int line_termination
, inter_name_termination
;
783 line_termination
= opt
->line_termination
;
784 inter_name_termination
= '\t';
785 if (!line_termination
)
786 inter_name_termination
= 0;
789 show_log(rev
, opt
->msg_sep
);
791 if (opt
->output_format
& DIFF_FORMAT_RAW
) {
792 offset
= strlen(COLONS
) - num_parent
;
795 prefix
= COLONS
+ offset
;
798 for (i
= 0; i
< num_parent
; i
++) {
799 printf("%s%06o", prefix
, p
->parent
[i
].mode
);
802 printf("%s%06o", prefix
, p
->mode
);
805 for (i
= 0; i
< num_parent
; i
++)
806 printf(" %s", diff_unique_abbrev(p
->parent
[i
].sha1
,
808 printf(" %s ", diff_unique_abbrev(p
->sha1
, opt
->abbrev
));
811 if (opt
->output_format
& (DIFF_FORMAT_RAW
| DIFF_FORMAT_NAME_STATUS
)) {
812 for (i
= 0; i
< num_parent
; i
++)
813 putchar(p
->parent
[i
].status
);
814 putchar(inter_name_termination
);
817 if (line_termination
) {
818 if (quote_c_style(p
->path
, NULL
, NULL
, 0))
819 quote_c_style(p
->path
, NULL
, stdout
, 0);
821 printf("%s", p
->path
);
822 putchar(line_termination
);
825 printf("%s%c", p
->path
, line_termination
);
829 void show_combined_diff(struct combine_diff_path
*p
,
832 struct rev_info
*rev
)
834 struct diff_options
*opt
= &rev
->diffopt
;
837 if (opt
->output_format
& (DIFF_FORMAT_RAW
|
839 DIFF_FORMAT_NAME_STATUS
))
840 show_raw_diff(p
, num_parent
, rev
);
841 else if (opt
->output_format
& DIFF_FORMAT_PATCH
)
842 show_patch_diff(p
, num_parent
, dense
, rev
);
845 void diff_tree_combined(const unsigned char *sha1
,
846 const unsigned char parent
[][20],
849 struct rev_info
*rev
)
851 struct diff_options
*opt
= &rev
->diffopt
;
852 struct diff_options diffopts
;
853 struct combine_diff_path
*p
, *paths
= NULL
;
854 int i
, num_paths
, needsep
, show_log_first
;
857 diffopts
.output_format
= DIFF_FORMAT_NO_OUTPUT
;
858 diffopts
.recursive
= 1;
860 show_log_first
= !!rev
->loginfo
;
862 /* find set of paths that everybody touches */
863 for (i
= 0; i
< num_parent
; i
++) {
864 /* show stat against the first parent even
865 * when doing combined diff.
867 if (i
== 0 && opt
->output_format
& DIFF_FORMAT_DIFFSTAT
)
868 diffopts
.output_format
= DIFF_FORMAT_DIFFSTAT
;
870 diffopts
.output_format
= DIFF_FORMAT_NO_OUTPUT
;
871 diff_tree_sha1(parent
[i
], sha1
, "", &diffopts
);
872 diffcore_std(&diffopts
);
873 paths
= intersect_paths(paths
, i
, num_parent
);
875 if (show_log_first
&& i
== 0) {
876 show_log(rev
, opt
->msg_sep
);
877 if (rev
->verbose_header
&& opt
->output_format
)
878 putchar(opt
->line_termination
);
880 diff_flush(&diffopts
);
883 /* find out surviving paths */
884 for (num_paths
= 0, p
= paths
; p
; p
= p
->next
) {
889 if (opt
->output_format
& (DIFF_FORMAT_RAW
|
891 DIFF_FORMAT_NAME_STATUS
)) {
892 for (p
= paths
; p
; p
= p
->next
) {
894 show_raw_diff(p
, num_parent
, rev
);
898 else if (opt
->output_format
& DIFF_FORMAT_DIFFSTAT
)
900 if (opt
->output_format
& DIFF_FORMAT_PATCH
) {
902 putchar(opt
->line_termination
);
903 for (p
= paths
; p
; p
= p
->next
) {
905 show_patch_diff(p
, num_parent
, dense
,
911 /* Clean things up */
913 struct combine_diff_path
*tmp
= paths
;
919 void diff_tree_combined_merge(const unsigned char *sha1
,
920 int dense
, struct rev_info
*rev
)
923 const unsigned char (*parent
)[20];
924 struct commit
*commit
= lookup_commit(sha1
);
925 struct commit_list
*parents
;
928 for (parents
= commit
->parents
, num_parent
= 0;
930 parents
= parents
->next
, num_parent
++)
933 parent
= xmalloc(num_parent
* sizeof(*parent
));
934 for (parents
= commit
->parents
, num_parent
= 0;
936 parents
= parents
->next
, num_parent
++)
937 memcpy(parent
+ num_parent
, parents
->item
->object
.sha1
, 20);
938 diff_tree_combined(sha1
, parent
, num_parent
, dense
, rev
);