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