7 #include "reflog-walk.h"
9 #include "string-list.h"
11 #include "gpg-interface.h"
12 #include "sequencer.h"
14 struct decoration name_decoration
= { "object names" };
16 enum decoration_type
{
19 DECORATION_REF_REMOTE
,
26 static char decoration_colors
[][COLOR_MAXLEN
] = {
28 GIT_COLOR_BOLD_GREEN
, /* REF_LOCAL */
29 GIT_COLOR_BOLD_RED
, /* REF_REMOTE */
30 GIT_COLOR_BOLD_YELLOW
, /* REF_TAG */
31 GIT_COLOR_BOLD_MAGENTA
, /* REF_STASH */
32 GIT_COLOR_BOLD_CYAN
, /* REF_HEAD */
33 GIT_COLOR_BOLD_BLUE
, /* GRAFTED */
36 static const char *decorate_get_color(int decorate_use_color
, enum decoration_type ix
)
38 if (want_color(decorate_use_color
))
39 return decoration_colors
[ix
];
43 static int parse_decorate_color_slot(const char *slot
)
46 * We're comparing with 'ignore-case' on
47 * (because config.c sets them all tolower),
48 * but let's match the letters in the literal
49 * string values here with how they are
50 * documented in Documentation/config.txt, for
53 * We love being consistent, don't we?
55 if (!strcasecmp(slot
, "branch"))
56 return DECORATION_REF_LOCAL
;
57 if (!strcasecmp(slot
, "remoteBranch"))
58 return DECORATION_REF_REMOTE
;
59 if (!strcasecmp(slot
, "tag"))
60 return DECORATION_REF_TAG
;
61 if (!strcasecmp(slot
, "stash"))
62 return DECORATION_REF_STASH
;
63 if (!strcasecmp(slot
, "HEAD"))
64 return DECORATION_REF_HEAD
;
68 int parse_decorate_color_config(const char *var
, const int ofs
, const char *value
)
70 int slot
= parse_decorate_color_slot(var
+ ofs
);
74 return config_error_nonbool(var
);
75 color_parse(value
, var
, decoration_colors
[slot
]);
80 * log-tree.c uses DIFF_OPT_TST for determining whether to use color
81 * for showing the commit sha1, use the same check for --decorate
83 #define decorate_get_color_opt(o, ix) \
84 decorate_get_color((o)->use_color, ix)
86 static void add_name_decoration(enum decoration_type type
, const char *name
, struct object
*obj
)
88 int nlen
= strlen(name
);
89 struct name_decoration
*res
= xmalloc(sizeof(struct name_decoration
) + nlen
);
90 memcpy(res
->name
, name
, nlen
+ 1);
92 res
->next
= add_decoration(&name_decoration
, obj
, res
);
95 static int add_ref_decoration(const char *refname
, const unsigned char *sha1
, int flags
, void *cb_data
)
98 enum decoration_type type
= DECORATION_NONE
;
100 if (!prefixcmp(refname
, "refs/replace/")) {
101 unsigned char original_sha1
[20];
102 if (!read_replace_refs
)
104 if (get_sha1_hex(refname
+ 13, original_sha1
)) {
105 warning("invalid replace ref %s", refname
);
108 obj
= parse_object(original_sha1
);
110 add_name_decoration(DECORATION_GRAFTED
, "replaced", obj
);
114 obj
= parse_object(sha1
);
118 if (!prefixcmp(refname
, "refs/heads/"))
119 type
= DECORATION_REF_LOCAL
;
120 else if (!prefixcmp(refname
, "refs/remotes/"))
121 type
= DECORATION_REF_REMOTE
;
122 else if (!prefixcmp(refname
, "refs/tags/"))
123 type
= DECORATION_REF_TAG
;
124 else if (!strcmp(refname
, "refs/stash"))
125 type
= DECORATION_REF_STASH
;
126 else if (!strcmp(refname
, "HEAD"))
127 type
= DECORATION_REF_HEAD
;
129 if (!cb_data
|| *(int *)cb_data
== DECORATE_SHORT_REFS
)
130 refname
= prettify_refname(refname
);
131 add_name_decoration(type
, refname
, obj
);
132 while (obj
->type
== OBJ_TAG
) {
133 obj
= ((struct tag
*)obj
)->tagged
;
136 add_name_decoration(DECORATION_REF_TAG
, refname
, obj
);
141 static int add_graft_decoration(const struct commit_graft
*graft
, void *cb_data
)
143 struct commit
*commit
= lookup_commit(graft
->sha1
);
146 add_name_decoration(DECORATION_GRAFTED
, "grafted", &commit
->object
);
150 void load_ref_decorations(int flags
)
155 for_each_ref(add_ref_decoration
, &flags
);
156 head_ref(add_ref_decoration
, &flags
);
157 for_each_commit_graft(add_graft_decoration
, NULL
);
161 static void show_parents(struct commit
*commit
, int abbrev
)
163 struct commit_list
*p
;
164 for (p
= commit
->parents
; p
; p
= p
->next
) {
165 struct commit
*parent
= p
->item
;
166 printf(" %s", find_unique_abbrev(parent
->object
.sha1
, abbrev
));
170 static void show_children(struct rev_info
*opt
, struct commit
*commit
, int abbrev
)
172 struct commit_list
*p
= lookup_decoration(&opt
->children
, &commit
->object
);
173 for ( ; p
; p
= p
->next
) {
174 printf(" %s", find_unique_abbrev(p
->item
->object
.sha1
, abbrev
));
178 void show_decorations(struct rev_info
*opt
, struct commit
*commit
)
181 struct name_decoration
*decoration
;
182 const char *color_commit
=
183 diff_get_color_opt(&opt
->diffopt
, DIFF_COMMIT
);
184 const char *color_reset
=
185 decorate_get_color_opt(&opt
->diffopt
, DECORATION_NONE
);
187 if (opt
->show_source
&& commit
->util
)
188 printf("\t%s", (char *) commit
->util
);
189 if (!opt
->show_decorations
)
191 decoration
= lookup_decoration(&name_decoration
, &commit
->object
);
196 printf("%s", prefix
);
197 fputs(decorate_get_color_opt(&opt
->diffopt
, decoration
->type
),
199 if (decoration
->type
== DECORATION_REF_TAG
)
200 fputs("tag: ", stdout
);
201 printf("%s", decoration
->name
);
202 fputs(color_reset
, stdout
);
203 fputs(color_commit
, stdout
);
205 decoration
= decoration
->next
;
210 static unsigned int digits_in_number(unsigned int number
)
212 unsigned int i
= 10, result
= 1;
213 while (i
<= number
) {
220 void fmt_output_subject(struct strbuf
*filename
,
222 struct rev_info
*info
)
224 const char *suffix
= info
->patch_suffix
;
226 int start_len
= filename
->len
;
227 int max_len
= start_len
+ FORMAT_PATCH_NAME_MAX
- (strlen(suffix
) + 1);
229 if (0 < info
->reroll_count
)
230 strbuf_addf(filename
, "v%d-", info
->reroll_count
);
231 strbuf_addf(filename
, "%04d-%s", nr
, subject
);
233 if (max_len
< filename
->len
)
234 strbuf_setlen(filename
, max_len
);
235 strbuf_addstr(filename
, suffix
);
238 void fmt_output_commit(struct strbuf
*filename
,
239 struct commit
*commit
,
240 struct rev_info
*info
)
242 struct pretty_print_context ctx
= {0};
243 struct strbuf subject
= STRBUF_INIT
;
245 format_commit_message(commit
, "%f", &subject
, &ctx
);
246 fmt_output_subject(filename
, subject
.buf
, info
);
247 strbuf_release(&subject
);
250 void log_write_email_headers(struct rev_info
*opt
, struct commit
*commit
,
251 const char **subject_p
,
252 const char **extra_headers_p
,
253 int *need_8bit_cte_p
)
255 const char *subject
= NULL
;
256 const char *extra_headers
= opt
->extra_headers
;
257 const char *name
= sha1_to_hex(commit
->object
.sha1
);
259 *need_8bit_cte_p
= 0; /* unknown */
260 if (opt
->total
> 0) {
261 static char buffer
[64];
262 snprintf(buffer
, sizeof(buffer
),
263 "Subject: [%s%s%0*d/%d] ",
265 *opt
->subject_prefix
? " " : "",
266 digits_in_number(opt
->total
),
267 opt
->nr
, opt
->total
);
269 } else if (opt
->total
== 0 && opt
->subject_prefix
&& *opt
->subject_prefix
) {
270 static char buffer
[256];
271 snprintf(buffer
, sizeof(buffer
),
273 opt
->subject_prefix
);
276 subject
= "Subject: ";
279 printf("From %s Mon Sep 17 00:00:00 2001\n", name
);
280 graph_show_oneline(opt
->graph
);
281 if (opt
->message_id
) {
282 printf("Message-Id: <%s>\n", opt
->message_id
);
283 graph_show_oneline(opt
->graph
);
285 if (opt
->ref_message_ids
&& opt
->ref_message_ids
->nr
> 0) {
287 n
= opt
->ref_message_ids
->nr
;
288 printf("In-Reply-To: <%s>\n", opt
->ref_message_ids
->items
[n
-1].string
);
289 for (i
= 0; i
< n
; i
++)
290 printf("%s<%s>\n", (i
> 0 ? "\t" : "References: "),
291 opt
->ref_message_ids
->items
[i
].string
);
292 graph_show_oneline(opt
->graph
);
294 if (opt
->mime_boundary
) {
295 static char subject_buffer
[1024];
296 static char buffer
[1024];
297 struct strbuf filename
= STRBUF_INIT
;
298 *need_8bit_cte_p
= -1; /* NEVER */
299 snprintf(subject_buffer
, sizeof(subject_buffer
) - 1,
301 "MIME-Version: 1.0\n"
302 "Content-Type: multipart/mixed;"
303 " boundary=\"%s%s\"\n"
305 "This is a multi-part message in MIME "
308 "Content-Type: text/plain; "
309 "charset=UTF-8; format=fixed\n"
310 "Content-Transfer-Encoding: 8bit\n\n",
311 extra_headers
? extra_headers
: "",
312 mime_boundary_leader
, opt
->mime_boundary
,
313 mime_boundary_leader
, opt
->mime_boundary
);
314 extra_headers
= subject_buffer
;
316 if (opt
->numbered_files
)
317 strbuf_addf(&filename
, "%d", opt
->nr
);
319 fmt_output_commit(&filename
, commit
, opt
);
320 snprintf(buffer
, sizeof(buffer
) - 1,
322 "Content-Type: text/x-patch;"
324 "Content-Transfer-Encoding: 8bit\n"
325 "Content-Disposition: %s;"
326 " filename=\"%s\"\n\n",
327 mime_boundary_leader
, opt
->mime_boundary
,
329 opt
->no_inline
? "attachment" : "inline",
331 opt
->diffopt
.stat_sep
= buffer
;
332 strbuf_release(&filename
);
334 *subject_p
= subject
;
335 *extra_headers_p
= extra_headers
;
338 static void show_sig_lines(struct rev_info
*opt
, int status
, const char *bol
)
340 const char *color
, *reset
, *eol
;
342 color
= diff_get_color_opt(&opt
->diffopt
,
343 status
? DIFF_WHITESPACE
: DIFF_FRAGINFO
);
344 reset
= diff_get_color_opt(&opt
->diffopt
, DIFF_RESET
);
346 eol
= strchrnul(bol
, '\n');
347 printf("%s%.*s%s%s", color
, (int)(eol
- bol
), bol
, reset
,
349 bol
= (*eol
) ? (eol
+ 1) : eol
;
353 static void show_signature(struct rev_info
*opt
, struct commit
*commit
)
355 struct strbuf payload
= STRBUF_INIT
;
356 struct strbuf signature
= STRBUF_INIT
;
357 struct strbuf gpg_output
= STRBUF_INIT
;
360 if (parse_signed_commit(commit
->object
.sha1
, &payload
, &signature
) <= 0)
363 status
= verify_signed_buffer(payload
.buf
, payload
.len
,
364 signature
.buf
, signature
.len
,
366 if (status
&& !gpg_output
.len
)
367 strbuf_addstr(&gpg_output
, "No signature\n");
369 show_sig_lines(opt
, status
, gpg_output
.buf
);
372 strbuf_release(&gpg_output
);
373 strbuf_release(&payload
);
374 strbuf_release(&signature
);
377 static int which_parent(const unsigned char *sha1
, const struct commit
*commit
)
380 const struct commit_list
*parent
;
382 for (nth
= 0, parent
= commit
->parents
; parent
; parent
= parent
->next
) {
383 if (!hashcmp(parent
->item
->object
.sha1
, sha1
))
390 static int is_common_merge(const struct commit
*commit
)
392 return (commit
->parents
393 && commit
->parents
->next
394 && !commit
->parents
->next
->next
);
397 static void show_one_mergetag(struct rev_info
*opt
,
398 struct commit_extra_header
*extra
,
399 struct commit
*commit
)
401 unsigned char sha1
[20];
403 struct strbuf verify_message
;
405 size_t payload_size
, gpg_message_offset
;
407 hash_sha1_file(extra
->value
, extra
->len
, typename(OBJ_TAG
), sha1
);
408 tag
= lookup_tag(sha1
);
410 return; /* error message already given */
412 strbuf_init(&verify_message
, 256);
413 if (parse_tag_buffer(tag
, extra
->value
, extra
->len
))
414 strbuf_addstr(&verify_message
, "malformed mergetag\n");
415 else if (is_common_merge(commit
) &&
416 !hashcmp(tag
->tagged
->sha1
,
417 commit
->parents
->next
->item
->object
.sha1
))
418 strbuf_addf(&verify_message
,
419 "merged tag '%s'\n", tag
->tag
);
420 else if ((nth
= which_parent(tag
->tagged
->sha1
, commit
)) < 0)
421 strbuf_addf(&verify_message
, "tag %s names a non-parent %s\n",
422 tag
->tag
, tag
->tagged
->sha1
);
424 strbuf_addf(&verify_message
,
425 "parent #%d, tagged '%s'\n", nth
+ 1, tag
->tag
);
426 gpg_message_offset
= verify_message
.len
;
428 payload_size
= parse_signature(extra
->value
, extra
->len
);
429 if ((extra
->len
<= payload_size
) ||
430 (verify_signed_buffer(extra
->value
, payload_size
,
431 extra
->value
+ payload_size
,
432 extra
->len
- payload_size
,
434 verify_message
.len
<= gpg_message_offset
)) {
435 strbuf_addstr(&verify_message
, "No signature\n");
438 else if (strstr(verify_message
.buf
+ gpg_message_offset
,
439 ": Good signature from "))
444 show_sig_lines(opt
, status
, verify_message
.buf
);
445 strbuf_release(&verify_message
);
448 static void show_mergetag(struct rev_info
*opt
, struct commit
*commit
)
450 struct commit_extra_header
*extra
, *to_free
;
452 to_free
= read_commit_extra_headers(commit
, NULL
);
453 for (extra
= to_free
; extra
; extra
= extra
->next
) {
454 if (strcmp(extra
->key
, "mergetag"))
455 continue; /* not a merge tag */
456 show_one_mergetag(opt
, extra
, commit
);
458 free_commit_extra_headers(to_free
);
461 void show_log(struct rev_info
*opt
)
463 struct strbuf msgbuf
= STRBUF_INIT
;
464 struct log_info
*log
= opt
->loginfo
;
465 struct commit
*commit
= log
->commit
, *parent
= log
->parent
;
466 int abbrev_commit
= opt
->abbrev_commit
? opt
->abbrev
: 40;
467 const char *extra_headers
= opt
->extra_headers
;
468 struct pretty_print_context ctx
= {0};
471 if (!opt
->verbose_header
) {
472 graph_show_commit(opt
->graph
);
475 put_revision_mark(opt
, commit
);
476 fputs(find_unique_abbrev(commit
->object
.sha1
, abbrev_commit
), stdout
);
477 if (opt
->print_parents
)
478 show_parents(commit
, abbrev_commit
);
479 if (opt
->children
.name
)
480 show_children(opt
, commit
, abbrev_commit
);
481 show_decorations(opt
, commit
);
482 if (opt
->graph
&& !graph_is_commit_finished(opt
->graph
)) {
484 graph_show_remainder(opt
->graph
);
486 putchar(opt
->diffopt
.line_termination
);
491 * If use_terminator is set, we already handled any record termination
492 * at the end of the last record.
493 * Otherwise, add a diffopt.line_termination character before all
494 * entries but the first. (IOW, as a separator between entries)
496 if (opt
->shown_one
&& !opt
->use_terminator
) {
498 * If entries are separated by a newline, the output
499 * should look human-readable. If the last entry ended
500 * with a newline, print the graph output before this
501 * newline. Otherwise it will end up as a completely blank
502 * line and will look like a gap in the graph.
504 * If the entry separator is not a newline, the output is
505 * primarily intended for programmatic consumption, and we
506 * never want the extra graph output before the entry
509 if (opt
->diffopt
.line_termination
== '\n' &&
510 !opt
->missing_newline
)
511 graph_show_padding(opt
->graph
);
512 putchar(opt
->diffopt
.line_termination
);
517 * If the history graph was requested,
518 * print the graph, up to this commit's line
520 graph_show_commit(opt
->graph
);
523 * Print header line of header..
526 if (opt
->commit_format
== CMIT_FMT_EMAIL
) {
527 log_write_email_headers(opt
, commit
, &ctx
.subject
, &extra_headers
,
529 } else if (opt
->commit_format
!= CMIT_FMT_USERFORMAT
) {
530 fputs(diff_get_color_opt(&opt
->diffopt
, DIFF_COMMIT
), stdout
);
531 if (opt
->commit_format
!= CMIT_FMT_ONELINE
)
532 fputs("commit ", stdout
);
535 put_revision_mark(opt
, commit
);
536 fputs(find_unique_abbrev(commit
->object
.sha1
, abbrev_commit
),
538 if (opt
->print_parents
)
539 show_parents(commit
, abbrev_commit
);
540 if (opt
->children
.name
)
541 show_children(opt
, commit
, abbrev_commit
);
544 find_unique_abbrev(parent
->object
.sha1
,
546 show_decorations(opt
, commit
);
547 printf("%s", diff_get_color_opt(&opt
->diffopt
, DIFF_RESET
));
548 if (opt
->commit_format
== CMIT_FMT_ONELINE
) {
552 graph_show_oneline(opt
->graph
);
554 if (opt
->reflog_info
) {
556 * setup_revisions() ensures that opt->reflog_info
557 * and opt->graph cannot both be set,
558 * so we don't need to worry about printing the
561 show_reflog_message(opt
->reflog_info
,
562 opt
->commit_format
== CMIT_FMT_ONELINE
,
564 opt
->date_mode_explicit
);
565 if (opt
->commit_format
== CMIT_FMT_ONELINE
)
570 if (opt
->show_signature
) {
571 show_signature(opt
, commit
);
572 show_mergetag(opt
, commit
);
578 if (opt
->show_notes
) {
580 struct strbuf notebuf
= STRBUF_INIT
;
582 raw
= (opt
->commit_format
== CMIT_FMT_USERFORMAT
);
583 format_display_notes(commit
->object
.sha1
, ¬ebuf
,
584 get_log_output_encoding(), raw
);
585 ctx
.notes_message
= notebuf
.len
586 ? strbuf_detach(¬ebuf
, NULL
)
591 * And then the pretty-printed message itself
593 if (ctx
.need_8bit_cte
>= 0 && opt
->add_signoff
)
595 has_non_ascii(fmt_name(getenv("GIT_COMMITTER_NAME"),
596 getenv("GIT_COMMITTER_EMAIL")));
597 ctx
.date_mode
= opt
->date_mode
;
598 ctx
.date_mode_explicit
= opt
->date_mode_explicit
;
599 ctx
.abbrev
= opt
->diffopt
.abbrev
;
600 ctx
.after_subject
= extra_headers
;
601 ctx
.preserve_subject
= opt
->preserve_subject
;
602 ctx
.reflog_info
= opt
->reflog_info
;
603 ctx
.fmt
= opt
->commit_format
;
604 ctx
.mailmap
= opt
->mailmap
;
605 ctx
.color
= opt
->diffopt
.use_color
;
606 pretty_print_commit(&ctx
, commit
, &msgbuf
);
608 if (opt
->add_signoff
)
609 append_signoff(&msgbuf
, 0, APPEND_SIGNOFF_DEDUP
);
611 if ((ctx
.fmt
!= CMIT_FMT_USERFORMAT
) &&
612 ctx
.notes_message
&& *ctx
.notes_message
) {
613 if (ctx
.fmt
== CMIT_FMT_EMAIL
) {
614 strbuf_addstr(&msgbuf
, "---\n");
615 opt
->shown_dashes
= 1;
617 strbuf_addstr(&msgbuf
, ctx
.notes_message
);
620 if (opt
->show_log_size
) {
621 printf("log size %i\n", (int)msgbuf
.len
);
622 graph_show_oneline(opt
->graph
);
626 * Set opt->missing_newline if msgbuf doesn't
627 * end in a newline (including if it is empty)
629 if (!msgbuf
.len
|| msgbuf
.buf
[msgbuf
.len
- 1] != '\n')
630 opt
->missing_newline
= 1;
632 opt
->missing_newline
= 0;
635 graph_show_commit_msg(opt
->graph
, &msgbuf
);
637 fwrite(msgbuf
.buf
, sizeof(char), msgbuf
.len
, stdout
);
638 if (opt
->use_terminator
) {
639 if (!opt
->missing_newline
)
640 graph_show_padding(opt
->graph
);
641 putchar(opt
->diffopt
.line_termination
);
644 strbuf_release(&msgbuf
);
645 free(ctx
.notes_message
);
648 int log_tree_diff_flush(struct rev_info
*opt
)
650 opt
->shown_dashes
= 0;
651 diffcore_std(&opt
->diffopt
);
653 if (diff_queue_is_empty()) {
654 int saved_fmt
= opt
->diffopt
.output_format
;
655 opt
->diffopt
.output_format
= DIFF_FORMAT_NO_OUTPUT
;
656 diff_flush(&opt
->diffopt
);
657 opt
->diffopt
.output_format
= saved_fmt
;
661 if (opt
->loginfo
&& !opt
->no_commit_id
) {
663 if ((opt
->diffopt
.output_format
& ~DIFF_FORMAT_NO_OUTPUT
) &&
664 opt
->verbose_header
&&
665 opt
->commit_format
!= CMIT_FMT_ONELINE
) {
667 * When showing a verbose header (i.e. log message),
668 * and not in --pretty=oneline format, we would want
669 * an extra newline between the end of log and the
670 * diff/diffstat output for readability.
672 int pch
= DIFF_FORMAT_DIFFSTAT
| DIFF_FORMAT_PATCH
;
673 if (opt
->diffopt
.output_prefix
) {
674 struct strbuf
*msg
= NULL
;
675 msg
= opt
->diffopt
.output_prefix(&opt
->diffopt
,
676 opt
->diffopt
.output_prefix_data
);
677 fwrite(msg
->buf
, msg
->len
, 1, stdout
);
681 * We may have shown three-dashes line early
682 * between notes and the log message, in which
683 * case we only want a blank line after the
684 * notes without (an extra) three-dashes line.
685 * Otherwise, we show the three-dashes line if
686 * we are showing the patch with diffstat, but
687 * in that case, there is no extra blank line
688 * after the three-dashes line.
690 if (!opt
->shown_dashes
&&
691 (pch
& opt
->diffopt
.output_format
) == pch
)
696 diff_flush(&opt
->diffopt
);
700 static int do_diff_combined(struct rev_info
*opt
, struct commit
*commit
)
702 diff_tree_combined_merge(commit
, opt
->dense_combined_merges
, opt
);
703 return !opt
->loginfo
;
707 * Show the diff of a commit.
709 * Return true if we printed any log info messages
711 static int log_tree_diff(struct rev_info
*opt
, struct commit
*commit
, struct log_info
*log
)
714 struct commit_list
*parents
;
715 unsigned const char *sha1
= commit
->object
.sha1
;
717 if (!opt
->diff
&& !DIFF_OPT_TST(&opt
->diffopt
, EXIT_WITH_STATUS
))
721 parents
= commit
->parents
;
723 if (opt
->show_root_diff
) {
724 diff_root_tree_sha1(sha1
, "", &opt
->diffopt
);
725 log_tree_diff_flush(opt
);
727 return !opt
->loginfo
;
730 /* More than one parent? */
731 if (parents
&& parents
->next
) {
732 if (opt
->ignore_merges
)
734 else if (opt
->combine_merges
)
735 return do_diff_combined(opt
, commit
);
736 else if (opt
->first_parent_only
) {
738 * Generate merge log entry only for the first
739 * parent, showing summary diff of the others
742 diff_tree_sha1(parents
->item
->object
.sha1
, sha1
, "", &opt
->diffopt
);
743 log_tree_diff_flush(opt
);
744 return !opt
->loginfo
;
747 /* If we show individual diffs, show the parent info */
748 log
->parent
= parents
->item
;
753 struct commit
*parent
= parents
->item
;
755 diff_tree_sha1(parent
->object
.sha1
, sha1
, "", &opt
->diffopt
);
756 log_tree_diff_flush(opt
);
758 showed_log
|= !opt
->loginfo
;
760 /* Set up the log info for the next parent, if any.. */
761 parents
= parents
->next
;
764 log
->parent
= parents
->item
;
770 int log_tree_commit(struct rev_info
*opt
, struct commit
*commit
)
779 shown
= log_tree_diff(opt
, commit
, &log
);
780 if (!shown
&& opt
->loginfo
&& opt
->always_show_header
) {
786 maybe_flush_or_die(stdout
, "stdout");