]> git.ipfire.org Git - thirdparty/git.git/blame - log-tree.c
object-store.h: move struct object_info from cache.h
[thirdparty/git.git] / log-tree.c
CommitLineData
5f1c3f07 1#include "cache.h"
db757e8b 2#include "commit-reach.h"
b2141fc1 3#include "config.h"
5f1c3f07 4#include "diff.h"
41771fa4 5#include "hex.h"
cbd53a21 6#include "object-store.h"
109cd76d 7#include "repository.h"
7b90ab46 8#include "tmp-objdir.h"
5f1c3f07 9#include "commit.h"
cab4feb6 10#include "tag.h"
7fefda5c 11#include "graph.h"
5f1c3f07 12#include "log-tree.h"
db757e8b 13#include "merge-ort.h"
8860fd42 14#include "reflog-walk.h"
cab4feb6 15#include "refs.h"
b079c50e 16#include "string-list.h"
67a4b586 17#include "color.h"
0c37f1fc 18#include "gpg-interface.h"
959a2623 19#include "sequencer.h"
12da1d1f 20#include "line-log.h"
3ac68a93 21#include "help.h"
40ce4160 22#include "range-diff.h"
20323d10 23#include "strmap.h"
5f1c3f07 24
2608c249 25static struct decoration name_decoration = { "object names" };
76c61fbd
JH
26static int decoration_loaded;
27static int decoration_flags;
a7524128 28
67a4b586
NR
29static char decoration_colors[][COLOR_MAXLEN] = {
30 GIT_COLOR_RESET,
31 GIT_COLOR_BOLD_GREEN, /* REF_LOCAL */
32 GIT_COLOR_BOLD_RED, /* REF_REMOTE */
33 GIT_COLOR_BOLD_YELLOW, /* REF_TAG */
34 GIT_COLOR_BOLD_MAGENTA, /* REF_STASH */
35 GIT_COLOR_BOLD_CYAN, /* REF_HEAD */
76f5df30 36 GIT_COLOR_BOLD_BLUE, /* GRAFTED */
67a4b586
NR
37};
38
a73b3680
NTND
39static const char *color_decorate_slots[] = {
40 [DECORATION_REF_LOCAL] = "branch",
41 [DECORATION_REF_REMOTE] = "remoteBranch",
42 [DECORATION_REF_TAG] = "tag",
43 [DECORATION_REF_STASH] = "stash",
44 [DECORATION_REF_HEAD] = "HEAD",
09c4ba41 45 [DECORATION_GRAFTED] = "grafted",
a73b3680
NTND
46};
47
67a4b586
NR
48static const char *decorate_get_color(int decorate_use_color, enum decoration_type ix)
49{
daa0c3d9 50 if (want_color(decorate_use_color))
67a4b586
NR
51 return decoration_colors[ix];
52 return "";
53}
54
3ac68a93 55define_list_config_array(color_decorate_slots);
5e11bee6 56
8852117a 57int parse_decorate_color_config(const char *var, const char *slot_name, const char *value)
5e11bee6 58{
a73b3680 59 int slot = LOOKUP_CONFIG(color_decorate_slots, slot_name);
5e11bee6
NR
60 if (slot < 0)
61 return 0;
62 if (!value)
63 return config_error_nonbool(var);
f6c5a296 64 return color_parse(value, decoration_colors[slot]);
5e11bee6
NR
65}
66
67a4b586
NR
67/*
68 * log-tree.c uses DIFF_OPT_TST for determining whether to use color
69 * for showing the commit sha1, use the same check for --decorate
70 */
71#define decorate_get_color_opt(o, ix) \
f1c96261 72 decorate_get_color((o)->use_color, ix)
67a4b586 73
662174d2 74void add_name_decoration(enum decoration_type type, const char *name, struct object *obj)
cab4feb6 75{
96ffc06f
JK
76 struct name_decoration *res;
77 FLEX_ALLOC_STR(res, name, name);
a7524128 78 res->type = type;
cab4feb6
RS
79 res->next = add_decoration(&name_decoration, obj, res);
80}
81
2608c249
JK
82const struct name_decoration *get_name_decoration(const struct object *obj)
83{
0cc7380d 84 load_ref_decorations(NULL, DECORATE_SHORT_REFS);
2608c249
JK
85 return lookup_decoration(&name_decoration, obj);
86}
87
c9f7a793
DS
88static int match_ref_pattern(const char *refname,
89 const struct string_list_item *item)
90{
91 int matched = 0;
afe8a907 92 if (!item->util) {
c9f7a793
DS
93 if (!wildmatch(item->string, refname, 0))
94 matched = 1;
95 } else {
96 const char *rest;
97 if (skip_prefix(refname, item->string, &rest) &&
98 (!*rest || *rest == '/'))
99 matched = 1;
100 }
101 return matched;
102}
103
104static int ref_filter_match(const char *refname,
105 const struct decoration_filter *filter)
106{
107 struct string_list_item *item;
108 const struct string_list *exclude_patterns = filter->exclude_ref_pattern;
109 const struct string_list *include_patterns = filter->include_ref_pattern;
a6be5e67
DS
110 const struct string_list *exclude_patterns_config =
111 filter->exclude_ref_config_pattern;
c9f7a793
DS
112
113 if (exclude_patterns && exclude_patterns->nr) {
114 for_each_string_list_item(item, exclude_patterns) {
115 if (match_ref_pattern(refname, item))
116 return 0;
117 }
118 }
119
120 if (include_patterns && include_patterns->nr) {
c9f7a793 121 for_each_string_list_item(item, include_patterns) {
a6be5e67
DS
122 if (match_ref_pattern(refname, item))
123 return 1;
c9f7a793 124 }
a6be5e67
DS
125 return 0;
126 }
c9f7a793 127
a6be5e67
DS
128 if (exclude_patterns_config && exclude_patterns_config->nr) {
129 for_each_string_list_item(item, exclude_patterns_config) {
130 if (match_ref_pattern(refname, item))
131 return 0;
132 }
c9f7a793 133 }
a6be5e67 134
c9f7a793
DS
135 return 1;
136}
137
f124b730 138static int add_ref_decoration(const char *refname, const struct object_id *oid,
5cf88fd8 139 int flags UNUSED,
63e14ee2 140 void *cb_data)
cab4feb6 141{
94d421b8 142 int i;
5267d292 143 struct object *obj;
88473c8b 144 enum object_type objtype;
6afb265b 145 enum decoration_type deco_type = DECORATION_NONE;
65516f58 146 struct decoration_filter *filter = (struct decoration_filter *)cb_data;
97e61e0f 147 const char *git_replace_ref_base = ref_namespace[NAMESPACE_REPLACE].ref;
5267d292 148
c9f7a793 149 if (filter && !ref_filter_match(refname, filter))
65516f58 150 return 0;
429ad204 151
58d121b2 152 if (starts_with(refname, git_replace_ref_base)) {
3d79f657 153 struct object_id original_oid;
6ebd1caf 154 if (!read_replace_refs)
b9ad5002 155 return 0;
31a0ad54
JH
156 if (get_oid_hex(refname + strlen(git_replace_ref_base),
157 &original_oid)) {
5267d292
NTND
158 warning("invalid replace ref %s", refname);
159 return 0;
160 }
109cd76d 161 obj = parse_object(the_repository, &original_oid);
5267d292
NTND
162 if (obj)
163 add_name_decoration(DECORATION_GRAFTED, "replaced", obj);
164 return 0;
165 }
166
88473c8b
JK
167 objtype = oid_object_info(the_repository, oid, NULL);
168 if (objtype < 0)
cab4feb6 169 return 0;
88473c8b 170 obj = lookup_object_by_type(the_repository, oid, objtype);
a7524128 171
94d421b8
DS
172 for (i = 0; i < ARRAY_SIZE(ref_namespace); i++) {
173 struct ref_namespace_info *info = &ref_namespace[i];
174
175 if (!info->decoration)
176 continue;
177 if (info->exact) {
178 if (!strcmp(refname, info->ref)) {
179 deco_type = info->decoration;
180 break;
181 }
182 } else if (starts_with(refname, info->ref)) {
183 deco_type = info->decoration;
184 break;
185 }
186 }
a7524128 187
6afb265b 188 add_name_decoration(deco_type, refname, obj);
cab4feb6 189 while (obj->type == OBJ_TAG) {
d1ed8d6c
JK
190 if (!obj->parsed)
191 parse_object(the_repository, &obj->oid);
cab4feb6
RS
192 obj = ((struct tag *)obj)->tagged;
193 if (!obj)
194 break;
a7524128 195 add_name_decoration(DECORATION_REF_TAG, refname, obj);
cab4feb6
RS
196 }
197 return 0;
198}
199
76f5df30
NTND
200static int add_graft_decoration(const struct commit_graft *graft, void *cb_data)
201{
c1f5eb49 202 struct commit *commit = lookup_commit(the_repository, &graft->oid);
76f5df30
NTND
203 if (!commit)
204 return 0;
205 add_name_decoration(DECORATION_GRAFTED, "grafted", &commit->object);
206 return 0;
207}
208
65516f58 209void load_ref_decorations(struct decoration_filter *filter, int flags)
cab4feb6 210{
76c61fbd 211 if (!decoration_loaded) {
65516f58
RA
212 if (filter) {
213 struct string_list_item *item;
214 for_each_string_list_item(item, filter->exclude_ref_pattern) {
215 normalize_glob_ref(item, NULL, item->string);
216 }
217 for_each_string_list_item(item, filter->include_ref_pattern) {
218 normalize_glob_ref(item, NULL, item->string);
219 }
a6be5e67
DS
220 for_each_string_list_item(item, filter->exclude_ref_config_pattern) {
221 normalize_glob_ref(item, NULL, item->string);
222 }
65516f58 223 }
76c61fbd
JH
224 decoration_loaded = 1;
225 decoration_flags = flags;
65516f58
RA
226 for_each_ref(add_ref_decoration, filter);
227 head_ref(add_ref_decoration, filter);
228 for_each_commit_graft(add_graft_decoration, filter);
cab4feb6
RS
229 }
230}
231
4d7b0efc 232static void show_parents(struct commit *commit, int abbrev, FILE *file)
c8c893c6
LT
233{
234 struct commit_list *p;
235 for (p = commit->parents; p ; p = p->next) {
236 struct commit *parent = p->item;
aab9583f 237 fprintf(file, " %s", find_unique_abbrev(&parent->object.oid, abbrev));
c8c893c6
LT
238 }
239}
240
91b849b2
JS
241static void show_children(struct rev_info *opt, struct commit *commit, int abbrev)
242{
243 struct commit_list *p = lookup_decoration(&opt->children, &commit->object);
244 for ( ; p; p = p->next) {
aab9583f 245 fprintf(opt->diffopt.file, " %s", find_unique_abbrev(&p->item->object.oid, abbrev));
91b849b2
JS
246 }
247}
248
51ff0f27
JH
249/*
250 * Do we have HEAD in the output, and also the branch it points at?
251 * If so, find that decoration entry for that current branch.
252 */
253static const struct name_decoration *current_pointed_by_HEAD(const struct name_decoration *decoration)
254{
255 const struct name_decoration *list, *head = NULL;
256 const char *branch_name = NULL;
51ff0f27
JH
257 int rru_flags;
258
259 /* First find HEAD */
260 for (list = decoration; list; list = list->next)
261 if (list->type == DECORATION_REF_HEAD) {
262 head = list;
263 break;
264 }
265 if (!head)
266 return NULL;
267
268 /* Now resolve and find the matching current branch */
744c040b 269 branch_name = resolve_ref_unsafe("HEAD", 0, NULL, &rru_flags);
d79be498 270 if (!branch_name || !(rru_flags & REF_ISSYMREF))
51ff0f27 271 return NULL;
76c61fbd 272
429ad204 273 if (!starts_with(branch_name, "refs/"))
51ff0f27
JH
274 return NULL;
275
276 /* OK, do we have that ref in the list? */
277 for (list = decoration; list; list = list->next)
278 if ((list->type == DECORATION_REF_LOCAL) &&
279 !strcmp(branch_name, list->name)) {
280 return list;
281 }
282
283 return NULL;
284}
285
429ad204
JH
286static void show_name(struct strbuf *sb, const struct name_decoration *decoration)
287{
288 if (decoration_flags == DECORATE_SHORT_REFS)
289 strbuf_addstr(sb, prettify_refname(decoration->name));
290 else
291 strbuf_addstr(sb, decoration->name);
292}
293
9d3f002f 294/*
9271095c
HJ
295 * The caller makes sure there is no funny color before calling.
296 * format_decorations_extended makes sure the same after return.
9d3f002f 297 */
9271095c 298void format_decorations_extended(struct strbuf *sb,
9d3f002f 299 const struct commit *commit,
9271095c
HJ
300 int use_color,
301 const char *prefix,
302 const char *separator,
303 const char *suffix)
ca135e7a 304{
2608c249 305 const struct name_decoration *decoration;
51ff0f27 306 const struct name_decoration *current_and_HEAD;
67a4b586 307 const char *color_commit =
9d3f002f 308 diff_get_color(use_color, DIFF_COMMIT);
67a4b586 309 const char *color_reset =
9d3f002f 310 decorate_get_color(use_color, DECORATION_NONE);
ca135e7a 311
2608c249 312 decoration = get_name_decoration(&commit->object);
ca135e7a
LT
313 if (!decoration)
314 return;
51ff0f27
JH
315
316 current_and_HEAD = current_pointed_by_HEAD(decoration);
ca135e7a 317 while (decoration) {
51ff0f27
JH
318 /*
319 * When both current and HEAD are there, only
320 * show HEAD->current where HEAD would have
321 * appeared, skipping the entry for current.
322 */
323 if (decoration != current_and_HEAD) {
324 strbuf_addstr(sb, color_commit);
325 strbuf_addstr(sb, prefix);
326 strbuf_addstr(sb, color_reset);
327 strbuf_addstr(sb, decorate_get_color(use_color, decoration->type));
328 if (decoration->type == DECORATION_REF_TAG)
329 strbuf_addstr(sb, "tag: ");
330
429ad204 331 show_name(sb, decoration);
51ff0f27
JH
332
333 if (current_and_HEAD &&
334 decoration->type == DECORATION_REF_HEAD) {
51ff0f27
JH
335 strbuf_addstr(sb, " -> ");
336 strbuf_addstr(sb, color_reset);
337 strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type));
429ad204 338 show_name(sb, current_and_HEAD);
51ff0f27
JH
339 }
340 strbuf_addstr(sb, color_reset);
341
342 prefix = separator;
343 }
ca135e7a
LT
344 decoration = decoration->next;
345 }
9d3f002f 346 strbuf_addstr(sb, color_commit);
9271095c 347 strbuf_addstr(sb, suffix);
9d3f002f
NTND
348 strbuf_addstr(sb, color_reset);
349}
350
351void show_decorations(struct rev_info *opt, struct commit *commit)
352{
353 struct strbuf sb = STRBUF_INIT;
354
87be2523
NTND
355 if (opt->sources) {
356 char **slot = revision_sources_peek(opt->sources, commit);
357
358 if (slot && *slot)
359 fprintf(opt->diffopt.file, "\t%s", *slot);
360 }
9d3f002f
NTND
361 if (!opt->show_decorations)
362 return;
363 format_decorations(&sb, commit, opt->diffopt.use_color);
4d7b0efc 364 fputs(sb.buf, opt->diffopt.file);
9d3f002f 365 strbuf_release(&sb);
ca135e7a
LT
366}
367
e00de24b
JS
368static unsigned int digits_in_number(unsigned int number)
369{
370 unsigned int i = 10, result = 1;
371 while (i <= number) {
372 i *= 10;
373 result++;
374 }
375 return result;
376}
377
d28b5d47
JH
378void fmt_output_subject(struct strbuf *filename,
379 const char *subject,
021f2f4c 380 struct rev_info *info)
6fa8e627 381{
021f2f4c
JH
382 const char *suffix = info->patch_suffix;
383 int nr = info->nr;
d28b5d47 384 int start_len = filename->len;
3baf58bf 385 int max_len = start_len + info->patch_name_max - (strlen(suffix) + 1);
d28b5d47 386
db91988a
ZH
387 if (info->reroll_count) {
388 struct strbuf temp = STRBUF_INIT;
389
390 strbuf_addf(&temp, "v%s", info->reroll_count);
391 format_sanitized_subject(filename, temp.buf, temp.len);
392 strbuf_addstr(filename, "-");
393 strbuf_release(&temp);
394 }
d28b5d47
JH
395 strbuf_addf(filename, "%04d-%s", nr, subject);
396
397 if (max_len < filename->len)
398 strbuf_setlen(filename, max_len);
399 strbuf_addstr(filename, suffix);
400}
401
402void fmt_output_commit(struct strbuf *filename,
403 struct commit *commit,
404 struct rev_info *info)
405{
406 struct pretty_print_context ctx = {0};
407 struct strbuf subject = STRBUF_INIT;
408
409 format_commit_message(commit, "%f", &subject, &ctx);
410 fmt_output_subject(filename, subject.buf, info);
411 strbuf_release(&subject);
6fa8e627
SB
412}
413
8ffc8dc6
RS
414void fmt_output_email_subject(struct strbuf *sb, struct rev_info *opt)
415{
416 if (opt->total > 0) {
417 strbuf_addf(sb, "Subject: [%s%s%0*d/%d] ",
418 opt->subject_prefix,
419 *opt->subject_prefix ? " " : "",
420 digits_in_number(opt->total),
421 opt->nr, opt->total);
422 } else if (opt->total == 0 && opt->subject_prefix && *opt->subject_prefix) {
423 strbuf_addf(sb, "Subject: [%s] ",
424 opt->subject_prefix);
425 } else {
426 strbuf_addstr(sb, "Subject: ");
427 }
428}
429
108dab28 430void log_write_email_headers(struct rev_info *opt, struct commit *commit,
267123b4 431 const char **extra_headers_p,
50cd54ef 432 int *need_8bit_cte_p,
433 int maybe_multipart)
b02bd65f 434{
b02bd65f 435 const char *extra_headers = opt->extra_headers;
3a30aa17 436 const char *name = oid_to_hex(opt->zero_commit ?
14228447 437 null_oid() : &commit->object.oid);
267123b4
JH
438
439 *need_8bit_cte_p = 0; /* unknown */
b02bd65f 440
4d7b0efc 441 fprintf(opt->diffopt.file, "From %s Mon Sep 17 00:00:00 2001\n", name);
7fefda5c
AS
442 graph_show_oneline(opt->graph);
443 if (opt->message_id) {
4d7b0efc 444 fprintf(opt->diffopt.file, "Message-Id: <%s>\n", opt->message_id);
7fefda5c
AS
445 graph_show_oneline(opt->graph);
446 }
b079c50e
TR
447 if (opt->ref_message_ids && opt->ref_message_ids->nr > 0) {
448 int i, n;
449 n = opt->ref_message_ids->nr;
4d7b0efc 450 fprintf(opt->diffopt.file, "In-Reply-To: <%s>\n", opt->ref_message_ids->items[n-1].string);
b079c50e 451 for (i = 0; i < n; i++)
4d7b0efc 452 fprintf(opt->diffopt.file, "%s<%s>\n", (i > 0 ? "\t" : "References: "),
b079c50e 453 opt->ref_message_ids->items[i].string);
7fefda5c
AS
454 graph_show_oneline(opt->graph);
455 }
50cd54ef 456 if (opt->mime_boundary && maybe_multipart) {
d50b69b8
JK
457 static struct strbuf subject_buffer = STRBUF_INIT;
458 static struct strbuf buffer = STRBUF_INIT;
108dab28 459 struct strbuf filename = STRBUF_INIT;
267123b4 460 *need_8bit_cte_p = -1; /* NEVER */
d50b69b8
JK
461
462 strbuf_reset(&subject_buffer);
463 strbuf_reset(&buffer);
464
465 strbuf_addf(&subject_buffer,
b02bd65f
DB
466 "%s"
467 "MIME-Version: 1.0\n"
468 "Content-Type: multipart/mixed;"
469 " boundary=\"%s%s\"\n"
470 "\n"
471 "This is a multi-part message in MIME "
472 "format.\n"
473 "--%s%s\n"
474 "Content-Type: text/plain; "
475 "charset=UTF-8; format=fixed\n"
476 "Content-Transfer-Encoding: 8bit\n\n",
477 extra_headers ? extra_headers : "",
478 mime_boundary_leader, opt->mime_boundary,
479 mime_boundary_leader, opt->mime_boundary);
d50b69b8 480 extra_headers = subject_buffer.buf;
b02bd65f 481
38ec23ac
JH
482 if (opt->numbered_files)
483 strbuf_addf(&filename, "%d", opt->nr);
484 else
d28b5d47 485 fmt_output_commit(&filename, commit, opt);
d50b69b8 486 strbuf_addf(&buffer,
6b2fbaaf 487 "\n--%s%s\n"
b02bd65f 488 "Content-Type: text/x-patch;"
108dab28 489 " name=\"%s\"\n"
b02bd65f
DB
490 "Content-Transfer-Encoding: 8bit\n"
491 "Content-Disposition: %s;"
108dab28 492 " filename=\"%s\"\n\n",
b02bd65f 493 mime_boundary_leader, opt->mime_boundary,
108dab28 494 filename.buf,
b02bd65f 495 opt->no_inline ? "attachment" : "inline",
108dab28 496 filename.buf);
d50b69b8 497 opt->diffopt.stat_sep = buffer.buf;
108dab28 498 strbuf_release(&filename);
b02bd65f 499 }
b02bd65f
DB
500 *extra_headers_p = extra_headers;
501}
502
c6b3ec41
JH
503static void show_sig_lines(struct rev_info *opt, int status, const char *bol)
504{
505 const char *color, *reset, *eol;
506
507 color = diff_get_color_opt(&opt->diffopt,
508 status ? DIFF_WHITESPACE : DIFF_FRAGINFO);
509 reset = diff_get_color_opt(&opt->diffopt, DIFF_RESET);
510 while (*bol) {
511 eol = strchrnul(bol, '\n');
4d7b0efc 512 fprintf(opt->diffopt.file, "%s%.*s%s%s", color, (int)(eol - bol), bol, reset,
c6b3ec41 513 *eol ? "\n" : "");
cf3983d1 514 graph_show_oneline(opt->graph);
c6b3ec41
JH
515 bol = (*eol) ? (eol + 1) : eol;
516 }
517}
518
0c37f1fc
JH
519static void show_signature(struct rev_info *opt, struct commit *commit)
520{
521 struct strbuf payload = STRBUF_INIT;
522 struct strbuf signature = STRBUF_INIT;
67948981 523 struct signature_check sigc = { 0 };
0c37f1fc 524 int status;
0c37f1fc 525
1fb5cf0d 526 if (parse_signed_commit(commit, &payload, &signature, the_hash_algo) <= 0)
0c37f1fc
JH
527 goto out;
528
4bbf3780 529 sigc.payload_type = SIGNATURE_PAYLOAD_COMMIT;
02769437
FS
530 sigc.payload = strbuf_detach(&payload, &sigc.payload_len);
531 status = check_signature(&sigc, signature.buf, signature.len);
b5726a5d 532 if (status && !sigc.output)
67948981
HJI
533 show_sig_lines(opt, status, "No signature\n");
534 else
b5726a5d 535 show_sig_lines(opt, status, sigc.output);
67948981 536 signature_check_clear(&sigc);
0c37f1fc
JH
537
538 out:
0c37f1fc
JH
539 strbuf_release(&payload);
540 strbuf_release(&signature);
541}
542
a92ea68f 543static int which_parent(const struct object_id *oid, const struct commit *commit)
824958e5
JH
544{
545 int nth;
546 const struct commit_list *parent;
547
548 for (nth = 0, parent = commit->parents; parent; parent = parent->next) {
4a7e27e9 549 if (oideq(&parent->item->object.oid, oid))
824958e5
JH
550 return nth;
551 nth++;
552 }
553 return -1;
554}
555
d041ffa5
JH
556static int is_common_merge(const struct commit *commit)
557{
558 return (commit->parents
559 && commit->parents->next
560 && !commit->parents->next->next);
561}
562
fef461ea
JS
563static int show_one_mergetag(struct commit *commit,
564 struct commit_extra_header *extra,
565 void *data)
824958e5 566{
063da62b 567 struct rev_info *opt = (struct rev_info *)data;
a92ea68f 568 struct object_id oid;
824958e5
JH
569 struct tag *tag;
570 struct strbuf verify_message;
67948981 571 struct signature_check sigc = { 0 };
824958e5 572 int status, nth;
482c1191 573 struct strbuf payload = STRBUF_INIT;
574 struct strbuf signature = STRBUF_INIT;
824958e5 575
2dcde20e 576 hash_object_file(the_hash_algo, extra->value, extra->len,
44439c1c 577 OBJ_TAG, &oid);
ce71efb7 578 tag = lookup_tag(the_repository, &oid);
824958e5 579 if (!tag)
fef461ea 580 return -1; /* error message already given */
824958e5
JH
581
582 strbuf_init(&verify_message, 256);
0e740fed 583 if (parse_tag_buffer(the_repository, tag, extra->value, extra->len))
824958e5 584 strbuf_addstr(&verify_message, "malformed mergetag\n");
d041ffa5 585 else if (is_common_merge(commit) &&
4a7e27e9
JK
586 oideq(&tag->tagged->oid,
587 &commit->parents->next->item->object.oid))
d041ffa5
JH
588 strbuf_addf(&verify_message,
589 "merged tag '%s'\n", tag->tag);
a92ea68f 590 else if ((nth = which_parent(&tag->tagged->oid, commit)) < 0)
824958e5 591 strbuf_addf(&verify_message, "tag %s names a non-parent %s\n",
237a2817 592 tag->tag, oid_to_hex(&tag->tagged->oid));
824958e5
JH
593 else
594 strbuf_addf(&verify_message,
595 "parent #%d, tagged '%s'\n", nth + 1, tag->tag);
824958e5 596
1315093f 597 status = -1;
482c1191 598 if (parse_signature(extra->value, extra->len, &payload, &signature)) {
42c55ce4 599 /* could have a good signature */
4bbf3780 600 sigc.payload_type = SIGNATURE_PAYLOAD_TAG;
02769437
FS
601 sigc.payload = strbuf_detach(&payload, &sigc.payload_len);
602 status = check_signature(&sigc, signature.buf, signature.len);
b5726a5d
FS
603 if (sigc.output)
604 strbuf_addstr(&verify_message, sigc.output);
67948981 605 else
42c55ce4 606 strbuf_addstr(&verify_message, "No signature\n");
67948981 607 signature_check_clear(&sigc);
42c55ce4
MG
608 /* otherwise we couldn't verify, which is shown as bad */
609 }
824958e5
JH
610
611 show_sig_lines(opt, status, verify_message.buf);
612 strbuf_release(&verify_message);
482c1191 613 strbuf_release(&payload);
614 strbuf_release(&signature);
fef461ea 615 return 0;
824958e5
JH
616}
617
fef461ea 618static int show_mergetag(struct rev_info *opt, struct commit *commit)
824958e5 619{
fef461ea 620 return for_each_mergetag(show_one_mergetag, commit, opt);
824958e5
JH
621}
622
3fcc7a23
ES
623static void next_commentary_block(struct rev_info *opt, struct strbuf *sb)
624{
625 const char *x = opt->shown_dashes ? "\n" : "---\n";
626 if (sb)
627 strbuf_addstr(sb, x);
628 else
629 fputs(x, opt->diffopt.file);
630 opt->shown_dashes = 1;
631}
632
02865655 633void show_log(struct rev_info *opt)
91539833 634{
f285a2d7 635 struct strbuf msgbuf = STRBUF_INIT;
39bc9a6c 636 struct log_info *log = opt->loginfo;
91539833 637 struct commit *commit = log->commit, *parent = log->parent;
2ed1960a 638 int abbrev_commit = opt->abbrev_commit ? opt->abbrev : the_hash_algo->hexsz;
dd2e794a
TR
639 const char *extra_headers = opt->extra_headers;
640 struct pretty_print_context ctx = {0};
91539833
LT
641
642 opt->loginfo = NULL;
643 if (!opt->verbose_header) {
7fefda5c
AS
644 graph_show_commit(opt->graph);
645
1df2d656 646 if (!opt->graph)
b1b47554 647 put_revision_mark(opt, commit);
aab9583f 648 fputs(find_unique_abbrev(&commit->object.oid, abbrev_commit), opt->diffopt.file);
885cf808 649 if (opt->print_parents)
4d7b0efc 650 show_parents(commit, abbrev_commit, opt->diffopt.file);
91b849b2
JS
651 if (opt->children.name)
652 show_children(opt, commit, abbrev_commit);
0f3a290b 653 show_decorations(opt, commit);
7fefda5c 654 if (opt->graph && !graph_is_commit_finished(opt->graph)) {
4d7b0efc 655 putc('\n', opt->diffopt.file);
7fefda5c
AS
656 graph_show_remainder(opt->graph);
657 }
4d7b0efc 658 putc(opt->diffopt.line_termination, opt->diffopt.file);
91539833
LT
659 return;
660 }
661
662 /*
8715227d
JK
663 * If use_terminator is set, we already handled any record termination
664 * at the end of the last record.
02865655
AS
665 * Otherwise, add a diffopt.line_termination character before all
666 * entries but the first. (IOW, as a separator between entries)
91539833 667 */
7fefda5c
AS
668 if (opt->shown_one && !opt->use_terminator) {
669 /*
670 * If entries are separated by a newline, the output
671 * should look human-readable. If the last entry ended
672 * with a newline, print the graph output before this
673 * newline. Otherwise it will end up as a completely blank
674 * line and will look like a gap in the graph.
675 *
676 * If the entry separator is not a newline, the output is
677 * primarily intended for programmatic consumption, and we
678 * never want the extra graph output before the entry
679 * separator.
680 */
681 if (opt->diffopt.line_termination == '\n' &&
682 !opt->missing_newline)
683 graph_show_padding(opt->graph);
4d7b0efc 684 putc(opt->diffopt.line_termination, opt->diffopt.file);
7fefda5c 685 }
91539833
LT
686 opt->shown_one = 1;
687
7fefda5c
AS
688 /*
689 * If the history graph was requested,
690 * print the graph, up to this commit's line
691 */
692 graph_show_commit(opt->graph);
693
91539833
LT
694 /*
695 * Print header line of header..
696 */
3eefc189 697
9f23e040 698 if (cmit_fmt_is_mail(opt->commit_format)) {
6d167fd7 699 log_write_email_headers(opt, commit, &extra_headers,
50cd54ef 700 &ctx.need_8bit_cte, 1);
6d167fd7
RS
701 ctx.rev = opt;
702 ctx.print_email_subject = 1;
e52a5de4 703 } else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
4d7b0efc 704 fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), opt->diffopt.file);
74bd9029 705 if (opt->commit_format != CMIT_FMT_ONELINE)
4d7b0efc 706 fputs("commit ", opt->diffopt.file);
7528f27d 707
1df2d656 708 if (!opt->graph)
b1b47554 709 put_revision_mark(opt, commit);
aab9583f 710 fputs(find_unique_abbrev(&commit->object.oid,
711 abbrev_commit),
4d7b0efc 712 opt->diffopt.file);
885cf808 713 if (opt->print_parents)
4d7b0efc 714 show_parents(commit, abbrev_commit, opt->diffopt.file);
91b849b2
JS
715 if (opt->children.name)
716 show_children(opt, commit, abbrev_commit);
73f0a157 717 if (parent)
4d7b0efc 718 fprintf(opt->diffopt.file, " (from %s)",
aab9583f 719 find_unique_abbrev(&parent->object.oid, abbrev_commit));
4d7b0efc 720 fputs(diff_get_color_opt(&opt->diffopt, DIFF_RESET), opt->diffopt.file);
0f3a290b 721 show_decorations(opt, commit);
7fefda5c 722 if (opt->commit_format == CMIT_FMT_ONELINE) {
4d7b0efc 723 putc(' ', opt->diffopt.file);
7fefda5c 724 } else {
4d7b0efc 725 putc('\n', opt->diffopt.file);
7fefda5c
AS
726 graph_show_oneline(opt->graph);
727 }
903b45fe 728 if (opt->reflog_info) {
7fefda5c
AS
729 /*
730 * setup_revisions() ensures that opt->reflog_info
731 * and opt->graph cannot both be set,
732 * so we don't need to worry about printing the
733 * graph info here.
734 */
4d12a471 735 show_reflog_message(opt->reflog_info,
55ccf85a 736 opt->commit_format == CMIT_FMT_ONELINE,
a5481a6c 737 &opt->date_mode,
55ccf85a 738 opt->date_mode_explicit);
02865655 739 if (opt->commit_format == CMIT_FMT_ONELINE)
903b45fe 740 return;
903b45fe 741 }
3eefc189 742 }
91539833 743
824958e5 744 if (opt->show_signature) {
0c37f1fc 745 show_signature(opt, commit);
824958e5
JH
746 show_mergetag(opt, commit);
747 }
0c37f1fc 748
ddf333f6
JH
749 if (opt->show_notes) {
750 int raw;
751 struct strbuf notebuf = STRBUF_INIT;
752
753 raw = (opt->commit_format == CMIT_FMT_USERFORMAT);
fb61e4d3 754 format_display_notes(&commit->object.oid, &notebuf,
ddf333f6 755 get_log_output_encoding(), raw);
82f51af3 756 ctx.notes_message = strbuf_detach(&notebuf, NULL);
ddf333f6
JH
757 }
758
91539833
LT
759 /*
760 * And then the pretty-printed message itself
761 */
5289c56a
NTND
762 if (ctx.need_8bit_cte >= 0 && opt->add_signoff)
763 ctx.need_8bit_cte =
39ab4d09 764 has_non_ascii(fmt_name(WANT_COMMITTER_IDENT));
dd2e794a 765 ctx.date_mode = opt->date_mode;
f026c756 766 ctx.date_mode_explicit = opt->date_mode_explicit;
dd2e794a
TR
767 ctx.abbrev = opt->diffopt.abbrev;
768 ctx.after_subject = extra_headers;
9553d2b2 769 ctx.preserve_subject = opt->preserve_subject;
19d097e3 770 ctx.encode_email_headers = opt->encode_email_headers;
8f8f5476 771 ctx.reflog_info = opt->reflog_info;
6bf13944 772 ctx.fmt = opt->commit_format;
0e2913b0 773 ctx.mailmap = opt->mailmap;
30825178 774 ctx.color = opt->diffopt.use_color;
7cc13c71 775 ctx.expand_tabs_in_log = opt->expand_tabs_in_log;
ecaee805 776 ctx.output_encoding = get_log_output_encoding();
ad6f028f 777 ctx.rev = opt;
a9080475
JK
778 if (opt->from_ident.mail_begin && opt->from_ident.name_begin)
779 ctx.from_ident = &opt->from_ident;
3ad87c80
JK
780 if (opt->graph)
781 ctx.graph_width = graph_width(opt->graph);
6bf13944 782 pretty_print_commit(&ctx, commit, &msgbuf);
212620fe
JH
783
784 if (opt->add_signoff)
5289c56a 785 append_signoff(&msgbuf, 0, APPEND_SIGNOFF_DEDUP);
212620fe 786
5a664cf2 787 if ((ctx.fmt != CMIT_FMT_USERFORMAT) &&
bd1470b8 788 ctx.notes_message && *ctx.notes_message) {
3fcc7a23
ES
789 if (cmit_fmt_is_mail(ctx.fmt))
790 next_commentary_block(opt, &msgbuf);
5a664cf2 791 strbuf_addstr(&msgbuf, ctx.notes_message);
bd1470b8 792 }
cf2251b6 793
7fefda5c 794 if (opt->show_log_size) {
4d7b0efc 795 fprintf(opt->diffopt.file, "log size %i\n", (int)msgbuf.len);
7fefda5c
AS
796 graph_show_oneline(opt->graph);
797 }
9fa3465d 798
7fefda5c
AS
799 /*
800 * Set opt->missing_newline if msgbuf doesn't
801 * end in a newline (including if it is empty)
802 */
803 if (!msgbuf.len || msgbuf.buf[msgbuf.len - 1] != '\n')
804 opt->missing_newline = 1;
805 else
806 opt->missing_newline = 0;
807
660e113c 808 graph_show_commit_msg(opt->graph, opt->diffopt.file, &msgbuf);
b9c7d6e4 809 if (opt->use_terminator && !commit_format_is_empty(opt->commit_format)) {
7fefda5c
AS
810 if (!opt->missing_newline)
811 graph_show_padding(opt->graph);
4d7b0efc 812 putc(opt->diffopt.line_termination, opt->diffopt.file);
7fefda5c
AS
813 }
814
674d1727 815 strbuf_release(&msgbuf);
ddf333f6 816 free(ctx.notes_message);
ee6cbf71
ES
817
818 if (cmit_fmt_is_mail(ctx.fmt) && opt->idiff_oid1) {
819 struct diff_queue_struct dq;
820
821 memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
822 DIFF_QUEUE_CLEAR(&diff_queued_diff);
823
824 next_commentary_block(opt, NULL);
825 fprintf_ln(opt->diffopt.file, "%s", opt->idiff_title);
72a72390
ES
826 show_interdiff(opt->idiff_oid1, opt->idiff_oid2, 2,
827 &opt->diffopt);
ee6cbf71
ES
828
829 memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
830 }
40ce4160
ES
831
832 if (cmit_fmt_is_mail(ctx.fmt) && opt->rdiff1) {
833 struct diff_queue_struct dq;
ac0edf1f 834 struct diff_options opts;
f1ce6c19
JS
835 struct range_diff_options range_diff_opts = {
836 .creation_factor = opt->creation_factor,
837 .dual_color = 1,
838 .diffopt = &opts
839 };
40ce4160
ES
840
841 memcpy(&dq, &diff_queued_diff, sizeof(diff_queued_diff));
842 DIFF_QUEUE_CLEAR(&diff_queued_diff);
843
844 next_commentary_block(opt, NULL);
845 fprintf_ln(opt->diffopt.file, "%s", opt->rdiff_title);
ac0edf1f
846 /*
847 * Pass minimum required diff-options to range-diff; others
848 * can be added later if deemed desirable.
849 */
850 diff_setup(&opts);
851 opts.file = opt->diffopt.file;
852 opts.use_color = opt->diffopt.use_color;
853 diff_setup_done(&opts);
f1ce6c19 854 show_range_diff(opt->rdiff1, opt->rdiff2, &range_diff_opts);
40ce4160
ES
855
856 memcpy(&diff_queued_diff, &dq, sizeof(diff_queued_diff));
857 }
91539833
LT
858}
859
cd2bdc53 860int log_tree_diff_flush(struct rev_info *opt)
5f1c3f07 861{
bd1470b8 862 opt->shown_dashes = 0;
5f1c3f07 863 diffcore_std(&opt->diffopt);
91539833 864
95433eee 865 if (diff_queue_is_empty(&opt->diffopt)) {
5f1c3f07
JH
866 int saved_fmt = opt->diffopt.output_format;
867 opt->diffopt.output_format = DIFF_FORMAT_NO_OUTPUT;
868 diff_flush(&opt->diffopt);
869 opt->diffopt.output_format = saved_fmt;
870 return 0;
871 }
91539833 872
3969cf7d 873 if (opt->loginfo && !opt->no_commit_id) {
02865655 874 show_log(opt);
304b5af6
LT
875 if ((opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) &&
876 opt->verbose_header &&
b9c7d6e4
JK
877 opt->commit_format != CMIT_FMT_ONELINE &&
878 !commit_format_is_empty(opt->commit_format)) {
1d34c50f
JH
879 /*
880 * When showing a verbose header (i.e. log message),
881 * and not in --pretty=oneline format, we would want
882 * an extra newline between the end of log and the
883 * diff/diffstat output for readability.
884 */
3969cf7d 885 int pch = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_PATCH;
81bd1b2a
BY
886 if (opt->diffopt.output_prefix) {
887 struct strbuf *msg = NULL;
888 msg = opt->diffopt.output_prefix(&opt->diffopt,
889 opt->diffopt.output_prefix_data);
4d7b0efc 890 fwrite(msg->buf, msg->len, 1, opt->diffopt.file);
81bd1b2a 891 }
1d34c50f
JH
892
893 /*
894 * We may have shown three-dashes line early
3fcc7a23
ES
895 * between generated commentary (notes, etc.)
896 * and the log message, in which case we only
897 * want a blank line after the commentary
898 * without (an extra) three-dashes line.
1d34c50f
JH
899 * Otherwise, we show the three-dashes line if
900 * we are showing the patch with diffstat, but
901 * in that case, there is no extra blank line
902 * after the three-dashes line.
903 */
904 if (!opt->shown_dashes &&
905 (pch & opt->diffopt.output_format) == pch)
4d7b0efc
JS
906 fprintf(opt->diffopt.file, "---");
907 putc('\n', opt->diffopt.file);
3969cf7d
JH
908 }
909 }
5f1c3f07
JH
910 diff_flush(&opt->diffopt);
911 return 1;
912}
913
cd2bdc53 914static int do_diff_combined(struct rev_info *opt, struct commit *commit)
5f1c3f07 915{
d01141de 916 diff_tree_combined_merge(commit, opt);
91539833 917 return !opt->loginfo;
5f1c3f07
JH
918}
919
20323d10
EN
920static void setup_additional_headers(struct diff_options *o,
921 struct strmap *all_headers)
922{
923 struct hashmap_iter iter;
924 struct strmap_entry *entry;
925
926 /*
927 * Make o->additional_path_headers contain the subset of all_headers
928 * that match o->pathspec. If there aren't any that match o->pathspec,
929 * then make o->additional_path_headers be NULL.
930 */
931
932 if (!o->pathspec.nr) {
933 o->additional_path_headers = all_headers;
934 return;
935 }
936
937 o->additional_path_headers = xmalloc(sizeof(struct strmap));
938 strmap_init_with_options(o->additional_path_headers, NULL, 0);
939 strmap_for_each_entry(all_headers, &iter, entry) {
940 if (match_pathspec(the_repository->index, &o->pathspec,
941 entry->key, strlen(entry->key),
942 0 /* prefix */, NULL /* seen */,
943 0 /* is_dir */))
944 strmap_put(o->additional_path_headers,
945 entry->key, entry->value);
946 }
947 if (!strmap_get_size(o->additional_path_headers)) {
948 strmap_clear(o->additional_path_headers, 0);
949 FREE_AND_NULL(o->additional_path_headers);
950 }
951}
952
953static void cleanup_additional_headers(struct diff_options *o)
954{
955 if (!o->pathspec.nr) {
956 o->additional_path_headers = NULL;
957 return;
958 }
959 if (!o->additional_path_headers)
960 return;
961
962 strmap_clear(o->additional_path_headers, 0);
963 FREE_AND_NULL(o->additional_path_headers);
964}
965
db757e8b
EN
966static int do_remerge_diff(struct rev_info *opt,
967 struct commit_list *parents,
e2841f70 968 struct object_id *oid)
db757e8b
EN
969{
970 struct merge_options o;
971 struct commit_list *bases;
972 struct merge_result res = {0};
973 struct pretty_print_context ctx = {0};
974 struct commit *parent1 = parents->item;
975 struct commit *parent2 = parents->next->item;
976 struct strbuf parent1_desc = STRBUF_INIT;
977 struct strbuf parent2_desc = STRBUF_INIT;
978
979 /* Setup merge options */
980 init_merge_options(&o, the_repository);
981 o.show_rename_progress = 0;
20323d10
EN
982 o.record_conflict_msgs_as_headers = 1;
983 o.msg_header_prefix = "remerge";
db757e8b
EN
984
985 ctx.abbrev = DEFAULT_ABBREV;
986 format_commit_message(parent1, "%h (%s)", &parent1_desc, &ctx);
987 format_commit_message(parent2, "%h (%s)", &parent2_desc, &ctx);
988 o.branch1 = parent1_desc.buf;
989 o.branch2 = parent2_desc.buf;
990
991 /* Parse the relevant commits and get the merge bases */
992 parse_commit_or_die(parent1);
993 parse_commit_or_die(parent2);
994 bases = get_merge_bases(parent1, parent2);
995
996 /* Re-merge the parents */
997 merge_incore_recursive(&o, bases, parent1, parent2, &res);
998
999 /* Show the diff */
20323d10 1000 setup_additional_headers(&opt->diffopt, res.path_messages);
db757e8b
EN
1001 diff_tree_oid(&res.tree->object.oid, oid, "", &opt->diffopt);
1002 log_tree_diff_flush(opt);
1003
1004 /* Cleanup */
20323d10 1005 cleanup_additional_headers(&opt->diffopt);
db757e8b
EN
1006 strbuf_release(&parent1_desc);
1007 strbuf_release(&parent2_desc);
1008 merge_finalize(&o, &res);
7b90ab46
EN
1009
1010 /* Clean up the contents of the temporary object directory */
1011 if (opt->remerge_objdir)
1012 tmp_objdir_discard_objects(opt->remerge_objdir);
1013 else
1014 BUG("did a remerge diff without remerge_objdir?!?");
db757e8b
EN
1015
1016 return !opt->loginfo;
1017}
1018
91539833
LT
1019/*
1020 * Show the diff of a commit.
1021 *
1022 * Return true if we printed any log info messages
1023 */
1024static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log_info *log)
5f1c3f07 1025{
91539833 1026 int showed_log;
5f1c3f07 1027 struct commit_list *parents;
f2fd0760 1028 struct object_id *oid;
a6d19ecc
SO
1029 int is_merge;
1030 int all_need_diff = opt->diff || opt->diffopt.flags.exit_with_status;
5f1c3f07 1031
a6d19ecc 1032 if (!all_need_diff && !opt->merges_need_diff)
91539833
LT
1033 return 0;
1034
7059dccc 1035 parse_commit_or_die(commit);
2e27bd77 1036 oid = get_commit_tree_oid(commit);
d1b9b767 1037
53d00b39 1038 parents = get_saved_parents(opt, commit);
a6d19ecc
SO
1039 is_merge = parents && parents->next;
1040 if (!is_merge && !all_need_diff)
1041 return 0;
1042
1043 /* Root commit? */
91539833 1044 if (!parents) {
2b60356d 1045 if (opt->show_root_diff) {
7b8dea0c 1046 diff_root_tree_oid(oid, "", &opt->diffopt);
2b60356d
RS
1047 log_tree_diff_flush(opt);
1048 }
91539833 1049 return !opt->loginfo;
5f1c3f07
JH
1050 }
1051
a6d19ecc 1052 if (is_merge) {
db757e8b
EN
1053 int octopus = (parents->next->next != NULL);
1054
1055 if (opt->remerge_diff) {
1056 if (octopus) {
1057 show_log(opt);
1058 fprintf(opt->diffopt.file,
1059 "diff: warning: Skipping remerge-diff "
1060 "for octopus merges.\n");
1061 return 1;
1062 }
e2841f70 1063 return do_remerge_diff(opt, parents, oid);
db757e8b 1064 }
1a2c4d80 1065 if (opt->combine_merges)
5f1c3f07 1066 return do_diff_combined(opt, commit);
1a2c4d80
SO
1067 if (opt->separate_merges) {
1068 if (!opt->first_parent_merges) {
1069 /* Show parent info for multiple diffs */
1070 log->parent = parents->item;
1071 }
1072 } else
1073 return 0;
5f1c3f07
JH
1074 }
1075
91539833
LT
1076 showed_log = 0;
1077 for (;;) {
5f1c3f07 1078 struct commit *parent = parents->item;
5f1c3f07 1079
7059dccc 1080 parse_commit_or_die(parent);
2e27bd77 1081 diff_tree_oid(get_commit_tree_oid(parent),
66f414f8 1082 oid, "", &opt->diffopt);
91539833
LT
1083 log_tree_diff_flush(opt);
1084
1085 showed_log |= !opt->loginfo;
1086
1087 /* Set up the log info for the next parent, if any.. */
1088 parents = parents->next;
3291eea3 1089 if (!parents || opt->first_parent_merges)
91539833
LT
1090 break;
1091 log->parent = parents->item;
1092 opt->loginfo = log;
1093 }
1094 return showed_log;
1095}
1096
1097int log_tree_commit(struct rev_info *opt, struct commit *commit)
1098{
1099 struct log_info log;
e900d494
ÆAB
1100 int shown;
1101 /* maybe called by e.g. cmd_log_walk(), maybe stand-alone */
1102 int no_free = opt->diffopt.no_free;
91539833
LT
1103
1104 log.commit = commit;
1105 log.parent = NULL;
1106 opt->loginfo = &log;
e900d494 1107 opt->diffopt.no_free = 1;
91539833 1108
f8781bfd 1109 /* NEEDSWORK: no restoring of no_free? Why? */
12da1d1f
TR
1110 if (opt->line_level_traverse)
1111 return line_log_print(opt, commit);
1112
1b32dece 1113 if (opt->track_linear && !opt->linear && !opt->reverse_output_stage)
4d7b0efc 1114 fprintf(opt->diffopt.file, "\n%s\n", opt->break_bar);
3eefc189
JH
1115 shown = log_tree_diff(opt, commit, &log);
1116 if (!shown && opt->loginfo && opt->always_show_header) {
91539833 1117 log.parent = NULL;
02865655 1118 show_log(opt);
3eefc189 1119 shown = 1;
5f1c3f07 1120 }
1b32dece 1121 if (opt->track_linear && !opt->linear && opt->reverse_output_stage)
4d7b0efc 1122 fprintf(opt->diffopt.file, "\n%s\n", opt->break_bar);
91539833 1123 opt->loginfo = NULL;
4d7b0efc 1124 maybe_flush_or_die(opt->diffopt.file, "stdout");
e900d494
ÆAB
1125 opt->diffopt.no_free = no_free;
1126 diff_free(&opt->diffopt);
3eefc189 1127 return shown;
5f1c3f07 1128}