7 void show_log(struct rev_info *opt, struct log_info *log, const char *sep)
9 static char this_header[16384];
10 struct commit *commit = log->commit, *parent = log->parent;
11 int abbrev = opt->diffopt.abbrev;
12 int abbrev_commit = opt->abbrev_commit ? opt->abbrev : 40;
16 if (!opt->verbose_header) {
17 puts(sha1_to_hex(commit->object.sha1));
22 * Whitespace between commit messages, unless we are oneline
24 if (opt->shown_one && opt->commit_format != CMIT_FMT_ONELINE)
29 * Print header line of header..
32 opt->commit_format == CMIT_FMT_ONELINE ? "" : "commit ",
33 diff_unique_abbrev(commit->object.sha1, abbrev_commit));
35 printf(" (from %s)", diff_unique_abbrev(parent->object.sha1, abbrev_commit));
36 putchar(opt->commit_format == CMIT_FMT_ONELINE ? ' ' : '\n');
39 * And then the pretty-printed message itself
41 len = pretty_print_commit(opt->commit_format, commit, ~0u, this_header, sizeof(this_header), abbrev);
42 printf("%s%s", this_header, sep);
45 int log_tree_diff_flush(struct rev_info *opt)
47 diffcore_std(&opt->diffopt);
49 if (diff_queue_is_empty()) {
50 int saved_fmt = opt->diffopt.output_format;
51 opt->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
52 diff_flush(&opt->diffopt);
53 opt->diffopt.output_format = saved_fmt;
57 if (opt->loginfo && !opt->no_commit_id)
58 show_log(opt, opt->loginfo, "\n");
59 diff_flush(&opt->diffopt);
63 static int diff_root_tree(struct rev_info *opt,
64 const unsigned char *new, const char *base)
68 struct tree_desc empty, real;
70 tree = read_object_with_reference(new, tree_type, &real.size, NULL);
72 die("unable to read root tree (%s)", sha1_to_hex(new));
77 retval = diff_tree(&empty, &real, base, &opt->diffopt);
79 log_tree_diff_flush(opt);
83 static int do_diff_combined(struct rev_info *opt, struct commit *commit)
85 unsigned const char *sha1 = commit->object.sha1;
87 diff_tree_combined_merge(sha1, opt->dense_combined_merges, opt);
92 * Show the diff of a commit.
94 * Return true if we printed any log info messages
96 static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log_info *log)
99 struct commit_list *parents;
100 unsigned const char *sha1 = commit->object.sha1;
106 parents = commit->parents;
108 if (opt->show_root_diff)
109 diff_root_tree(opt, sha1, "");
110 return !opt->loginfo;
113 /* More than one parent? */
114 if (parents && parents->next) {
115 if (opt->ignore_merges)
117 else if (opt->combine_merges)
118 return do_diff_combined(opt, commit);
120 /* If we show individual diffs, show the parent info */
121 log->parent = parents->item;
126 struct commit *parent = parents->item;
128 diff_tree_sha1(parent->object.sha1, sha1, "", &opt->diffopt);
129 log_tree_diff_flush(opt);
131 showed_log |= !opt->loginfo;
133 /* Set up the log info for the next parent, if any.. */
134 parents = parents->next;
137 log->parent = parents->item;
143 int log_tree_commit(struct rev_info *opt, struct commit *commit)
151 if (!log_tree_diff(opt, commit, &log) && opt->loginfo && opt->always_show_header) {
153 show_log(opt, opt->loginfo, "");