]> git.ipfire.org Git - thirdparty/git.git/blame - builtin/rev-list.c
Sync with maint
[thirdparty/git.git] / builtin / rev-list.c
CommitLineData
64745109 1#include "cache.h"
b2141fc1 2#include "config.h"
64745109 3#include "commit.h"
c4e05b1a 4#include "diff.h"
ae563542 5#include "revision.h"
c64ed70d 6#include "list-objects.h"
caf3827e
JH
7#include "list-objects-filter.h"
8#include "list-objects-filter-options.h"
7c0fe330 9#include "object.h"
cbd53a21 10#include "object-store.h"
aa32939f
VM
11#include "pack.h"
12#include "pack-bitmap.h"
5fb61b8d 13#include "builtin.h"
50e62a8e 14#include "log-tree.h"
7fefda5c 15#include "graph.h"
a2ad79ce 16#include "bisect.h"
434ea3cd 17#include "progress.h"
7f97de5e 18#include "reflog-walk.h"
caf3827e 19#include "oidset.h"
df11e196 20#include "packfile.h"
8906300f 21
a6f68d47 22static const char rev_list_usage[] =
1b1dd23f 23"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
69e0c256 24" limiting output:\n"
62b4698e
ŠN
25" --max-count=<n>\n"
26" --max-age=<epoch>\n"
27" --min-age=<epoch>\n"
69e0c256
JH
28" --sparse\n"
29" --no-merges\n"
ad5aeede
MG
30" --min-parents=<n>\n"
31" --no-min-parents\n"
32" --max-parents=<n>\n"
33" --no-max-parents\n"
93b74bca 34" --remove-empty\n"
69e0c256 35" --all\n"
a5aa930d
UKK
36" --branches\n"
37" --tags\n"
38" --remotes\n"
42cabc34 39" --stdin\n"
27350891 40" --quiet\n"
69e0c256 41" ordering output:\n"
69e0c256 42" --topo-order\n"
4c8725f1 43" --date-order\n"
7ccd3667 44" --reverse\n"
69e0c256
JH
45" formatting output:\n"
46" --parents\n"
72276a3e 47" --children\n"
c6496575 48" --objects | --objects-edge\n"
69e0c256
JH
49" --unpacked\n"
50" --header | --pretty\n"
42357b4e 51" --[no-]object-names\n"
62b4698e 52" --abbrev=<n> | --no-abbrev\n"
5c51c985 53" --abbrev-commit\n"
b24bace5 54" --left-right\n"
75d2e5a7 55" --count\n"
69e0c256 56" special purpose:\n"
457f08a0 57" --bisect\n"
50e62a8e
CC
58" --bisect-vars\n"
59" --bisect-all"
69e0c256 60;
a6f68d47 61
434ea3cd
JK
62static struct progress *progress;
63static unsigned progress_counter;
64
caf3827e
JH
65static struct list_objects_filter_options filter_options;
66static struct oidset omitted_objects;
67static int arg_print_omitted; /* print objects omitted by filter */
68
69static struct oidset missing_objects;
70enum missing_action {
71 MA_ERROR = 0, /* fail if any missing objects are encountered */
72 MA_ALLOW_ANY, /* silently allow ALL missing objects */
73 MA_PRINT, /* print ALL missing objects in special section */
df11e196 74 MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */
caf3827e
JH
75};
76static enum missing_action arg_missing_action;
77
42357b4e
ES
78/* display only the oid of each object encountered */
79static int arg_show_object_names = 1;
80
caf3827e
JH
81#define DEFAULT_OIDSET_SIZE (16*1024)
82
d92349dd 83static void finish_commit(struct commit *commit);
11c211fa 84static void show_commit(struct commit *commit, void *data)
81f2bb1f 85{
d797257e
CC
86 struct rev_list_info *info = data;
87 struct rev_info *revs = info->revs;
11c211fa 88
434ea3cd
JK
89 display_progress(progress, ++progress_counter);
90
98993722 91 if (info->flags & REV_LIST_QUIET) {
d92349dd 92 finish_commit(commit);
98993722
NTND
93 return;
94 }
95
11c211fa 96 graph_show_commit(revs->graph);
7fefda5c 97
f69c5018 98 if (revs->count) {
b388e14b
MG
99 if (commit->object.flags & PATCHSAME)
100 revs->count_same++;
101 else if (commit->object.flags & SYMMETRIC_LEFT)
f69c5018
TR
102 revs->count_left++;
103 else
104 revs->count_right++;
d92349dd 105 finish_commit(commit);
f69c5018
TR
106 return;
107 }
108
d797257e 109 if (info->show_timestamp)
cb71f8bd 110 printf("%"PRItime" ", commit->date);
d797257e
CC
111 if (info->header_prefix)
112 fputs(info->header_prefix, stdout);
7528f27d 113
1df2d656
MG
114 if (!revs->graph)
115 fputs(get_revision_mark(revs, commit), stdout);
11c211fa 116 if (revs->abbrev_commit && revs->abbrev)
aab9583f 117 fputs(find_unique_abbrev(&commit->object.oid, revs->abbrev),
7594c4b2 118 stdout);
5c51c985 119 else
f2fd0760 120 fputs(oid_to_hex(&commit->object.oid), stdout);
11c211fa 121 if (revs->print_parents) {
81f2bb1f
LT
122 struct commit_list *parents = commit->parents;
123 while (parents) {
f2fd0760 124 printf(" %s", oid_to_hex(&parents->item->object.oid));
81f2bb1f
LT
125 parents = parents->next;
126 }
127 }
11c211fa 128 if (revs->children.name) {
72276a3e
JH
129 struct commit_list *children;
130
11c211fa 131 children = lookup_decoration(&revs->children, &commit->object);
72276a3e 132 while (children) {
f2fd0760 133 printf(" %s", oid_to_hex(&children->item->object.oid));
72276a3e
JH
134 children = children->next;
135 }
136 }
11c211fa
CC
137 show_decorations(revs, commit);
138 if (revs->commit_format == CMIT_FMT_ONELINE)
d87449c5
JH
139 putchar(' ');
140 else
141 putchar('\n');
142
7fa31b64 143 if (revs->verbose_header) {
f285a2d7 144 struct strbuf buf = STRBUF_INIT;
dd2e794a
TR
145 struct pretty_print_context ctx = {0};
146 ctx.abbrev = revs->abbrev;
147 ctx.date_mode = revs->date_mode;
f026c756 148 ctx.date_mode_explicit = revs->date_mode_explicit;
6bf13944 149 ctx.fmt = revs->commit_format;
ecaee805 150 ctx.output_encoding = get_log_output_encoding();
d75dfb10 151 ctx.color = revs->diffopt.use_color;
6bf13944 152 pretty_print_commit(&ctx, commit, &buf);
660e113c
JK
153 if (buf.len) {
154 if (revs->commit_format != CMIT_FMT_ONELINE)
155 graph_show_oneline(revs->graph);
7fefda5c 156
660e113c 157 graph_show_commit_msg(revs->graph, stdout, &buf);
7fefda5c 158
660e113c
JK
159 /*
160 * Add a newline after the commit message.
161 *
162 * Usually, this newline produces a blank
163 * padding line between entries, in which case
164 * we need to add graph padding on this line.
165 *
166 * However, the commit message may not end in a
167 * newline. In this case the newline simply
168 * ends the last line of the commit message,
169 * and we don't need any graph output. (This
170 * always happens with CMIT_FMT_ONELINE, and it
171 * happens with CMIT_FMT_USERFORMAT when the
172 * format doesn't explicitly end in a newline.)
173 */
174 if (buf.len && buf.buf[buf.len - 1] == '\n')
175 graph_show_padding(revs->graph);
98985c69 176 putchar(info->hdr_termination);
7fefda5c 177 } else {
660e113c
JK
178 /*
179 * If the message buffer is empty, just show
180 * the rest of the graph output for this
181 * commit.
182 */
183 if (graph_show_remainder(revs->graph))
184 putchar('\n');
185 if (revs->commit_format == CMIT_FMT_ONELINE)
186 putchar('\n');
7fefda5c 187 }
674d1727 188 strbuf_release(&buf);
7fefda5c 189 } else {
11c211fa 190 if (graph_show_remainder(revs->graph))
7fefda5c 191 putchar('\n');
7620d39f 192 }
06f59e9f 193 maybe_flush_or_die(stdout, "stdout");
d92349dd 194 finish_commit(commit);
27350891
SP
195}
196
d92349dd 197static void finish_commit(struct commit *commit)
27350891 198{
cb115748
LT
199 if (commit->parents) {
200 free_commit_list(commit->parents);
201 commit->parents = NULL;
202 }
6a7895fd
SB
203 free_commit_buffer(the_repository->parsed_objects,
204 commit);
a3437b8c
JS
205}
206
caf3827e
JH
207static inline void finish_object__ma(struct object *obj)
208{
df11e196
JT
209 /*
210 * Whether or not we try to dynamically fetch missing objects
211 * from the server, we currently DO NOT have the object. We
212 * can either print, allow (ignore), or conditionally allow
213 * (ignore) them.
214 */
caf3827e
JH
215 switch (arg_missing_action) {
216 case MA_ERROR:
7c0fe330
MD
217 die("missing %s object '%s'",
218 type_name(obj->type), oid_to_hex(&obj->oid));
caf3827e
JH
219 return;
220
221 case MA_ALLOW_ANY:
222 return;
223
224 case MA_PRINT:
225 oidset_insert(&missing_objects, &obj->oid);
226 return;
227
df11e196
JT
228 case MA_ALLOW_PROMISOR:
229 if (is_promisor_object(&obj->oid))
230 return;
7c0fe330
MD
231 die("unexpected missing %s object '%s'",
232 type_name(obj->type), oid_to_hex(&obj->oid));
df11e196
JT
233 return;
234
caf3827e
JH
235 default:
236 BUG("unhandled missing_action");
237 return;
238 }
239}
240
df11e196 241static int finish_object(struct object *obj, const char *name, void *cb_data)
27350891 242{
98993722 243 struct rev_list_info *info = cb_data;
f06ab027 244 if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {
caf3827e 245 finish_object__ma(obj);
df11e196
JT
246 return 1;
247 }
98993722 248 if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
109cd76d 249 parse_object(the_repository, &obj->oid);
df11e196 250 return 0;
27350891
SP
251}
252
de1e67d0 253static void show_object(struct object *obj, const char *name, void *cb_data)
9de48752 254{
cb8da705 255 struct rev_list_info *info = cb_data;
df11e196
JT
256 if (finish_object(obj, name, cb_data))
257 return;
434ea3cd 258 display_progress(progress, ++progress_counter);
98993722
NTND
259 if (info->flags & REV_LIST_QUIET)
260 return;
42357b4e
ES
261 if (arg_show_object_names)
262 show_object_with_name(stdout, obj, name);
263 else
264 printf("%s\n", oid_to_hex(&obj->oid));
9de48752
LT
265}
266
8d1d8f83
JH
267static void show_edge(struct commit *commit)
268{
f2fd0760 269 printf("-%s\n", oid_to_hex(&commit->object.oid));
8d1d8f83
JH
270}
271
38ef7507 272static void print_var_str(const char *var, const char *val)
280e65cb 273{
38ef7507 274 printf("%s='%s'\n", var, val);
280e65cb
CC
275}
276
38ef7507 277static void print_var_int(const char *var, int val)
280e65cb 278{
38ef7507 279 printf("%s=%d\n", var, val);
280e65cb
CC
280}
281
f1c92c63 282static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
9996983c 283{
98993722 284 int cnt, flags = info->flags;
dc01505f 285 char hex[GIT_MAX_HEXSZ + 1] = "";
95188648 286 struct commit_list *tried;
d797257e 287 struct rev_info *revs = info->revs;
9996983c 288
8ba8fe04 289 if (!revs->commits)
9996983c
CC
290 return 1;
291
9af3589e
CC
292 revs->commits = filter_skipped(revs->commits, &tried,
293 flags & BISECT_SHOW_ALL,
294 NULL, NULL);
95188648 295
9996983c 296 /*
7428d754 297 * revs->commits can reach "reaches" commits among
9996983c
CC
298 * "all" commits. If it is good, then there are
299 * (all-reaches) commits left to be bisected.
300 * On the other hand, if it is bad, then the set
301 * to bisect is "reaches".
302 * A bisect set of size N has (N-1) commits further
303 * to test, as we already know one bad one.
304 */
305 cnt = all - reaches;
306 if (cnt < reaches)
307 cnt = reaches;
6a17fad7 308
95188648 309 if (revs->commits)
2490574d 310 oid_to_hex_r(hex, &revs->commits->item->object.oid);
9996983c 311
37c4c38d 312 if (flags & BISECT_SHOW_ALL) {
d797257e 313 traverse_commit_list(revs, show_commit, show_object, info);
9996983c
CC
314 printf("------\n");
315 }
316
38ef7507
CC
317 print_var_str("bisect_rev", hex);
318 print_var_int("bisect_nr", cnt - 1);
319 print_var_int("bisect_good", all - reaches - 1);
320 print_var_int("bisect_bad", reaches - 1);
321 print_var_int("bisect_all", all);
322 print_var_int("bisect_steps", estimate_bisect_steps(all));
9996983c
CC
323
324 return 0;
325}
326
aa32939f 327static int show_object_fast(
20664967 328 const struct object_id *oid,
aa32939f
VM
329 enum object_type type,
330 int exclude,
331 uint32_t name_hash,
332 struct packed_git *found_pack,
333 off_t found_offset)
334{
20664967 335 fprintf(stdout, "%s\n", oid_to_hex(oid));
aa32939f
VM
336 return 1;
337}
338
caf3827e
JH
339static inline int parse_missing_action_value(const char *value)
340{
341 if (!strcmp(value, "error")) {
342 arg_missing_action = MA_ERROR;
343 return 1;
344 }
345
346 if (!strcmp(value, "allow-any")) {
347 arg_missing_action = MA_ALLOW_ANY;
df11e196 348 fetch_if_missing = 0;
caf3827e
JH
349 return 1;
350 }
351
352 if (!strcmp(value, "print")) {
353 arg_missing_action = MA_PRINT;
df11e196
JT
354 fetch_if_missing = 0;
355 return 1;
356 }
357
358 if (!strcmp(value, "allow-promisor")) {
359 arg_missing_action = MA_ALLOW_PROMISOR;
360 fetch_if_missing = 0;
caf3827e
JH
361 return 1;
362 }
363
364 return 0;
365}
366
a633fca0 367int cmd_rev_list(int argc, const char **argv, const char *prefix)
64745109 368{
11c211fa 369 struct rev_info revs;
d797257e 370 struct rev_list_info info;
bbcde41a
MD
371 struct setup_revision_opt s_r_opt = {
372 .allow_exclude_promisor_objects = 1,
373 };
d9a83684 374 int i;
ff62d732 375 int bisect_list = 0;
457f08a0 376 int bisect_show_vars = 0;
50e62a8e 377 int bisect_find_all = 0;
aa32939f 378 int use_bitmap_index = 0;
434ea3cd 379 const char *show_progress = NULL;
64745109 380
5a88f97c
JH
381 if (argc == 2 && !strcmp(argv[1], "-h"))
382 usage(rev_list_usage);
383
ef90d6d4 384 git_config(git_default_config, NULL);
2abf3503 385 repo_init_revisions(the_repository, &revs, prefix);
7337b138 386 revs.abbrev = DEFAULT_ABBREV;
7594c4b2 387 revs.commit_format = CMIT_FMT_UNSPECIFIED;
df11e196
JT
388
389 /*
390 * Scan the argument list before invoking setup_revisions(), so that we
391 * know if fetch_if_missing needs to be set to 0.
392 *
393 * "--exclude-promisor-objects" acts as a pre-filter on missing objects
394 * by not crossing the boundary from realized objects to promisor
395 * objects.
396 *
397 * Let "--missing" to conditionally set fetch_if_missing.
398 */
399 for (i = 1; i < argc; i++) {
400 const char *arg = argv[i];
401 if (!strcmp(arg, "--exclude-promisor-objects")) {
402 fetch_if_missing = 0;
403 revs.exclude_promisor_objects = 1;
404 break;
405 }
406 }
407 for (i = 1; i < argc; i++) {
408 const char *arg = argv[i];
409 if (skip_prefix(arg, "--missing=", &arg)) {
410 if (revs.exclude_promisor_objects)
411 die(_("cannot combine --exclude-promisor-objects and --missing"));
412 if (parse_missing_action_value(arg))
413 break;
414 }
415 }
416
ee4dfee2
JK
417 if (arg_missing_action)
418 revs.do_not_die_on_missing_tree = 1;
419
bbcde41a 420 argc = setup_revisions(argc, argv, &revs, &s_r_opt);
ae563542 421
d797257e
CC
422 memset(&info, 0, sizeof(info));
423 info.revs = &revs;
ad3f9a71
LT
424 if (revs.bisect)
425 bisect_list = 1;
d797257e 426
0d1e0e78 427 if (revs.diffopt.flags.quick)
98993722 428 info.flags |= REV_LIST_QUIET;
fcfda02b 429 for (i = 1 ; i < argc; i++) {
cf484544 430 const char *arg = argv[i];
fcfda02b 431
a6f68d47 432 if (!strcmp(arg, "--header")) {
7594c4b2 433 revs.verbose_header = 1;
9d97aa64
LT
434 continue;
435 }
dc68c4ff 436 if (!strcmp(arg, "--timestamp")) {
d797257e 437 info.show_timestamp = 1;
dc68c4ff
JH
438 continue;
439 }
8b3a1e05
LT
440 if (!strcmp(arg, "--bisect")) {
441 bisect_list = 1;
442 continue;
443 }
50e62a8e
CC
444 if (!strcmp(arg, "--bisect-all")) {
445 bisect_list = 1;
446 bisect_find_all = 1;
98993722 447 info.flags |= BISECT_SHOW_ALL;
6e46cc0d 448 revs.show_decorations = 1;
50e62a8e
CC
449 continue;
450 }
457f08a0
JH
451 if (!strcmp(arg, "--bisect-vars")) {
452 bisect_list = 1;
453 bisect_show_vars = 1;
454 continue;
455 }
aa32939f
VM
456 if (!strcmp(arg, "--use-bitmap-index")) {
457 use_bitmap_index = 1;
458 continue;
459 }
460 if (!strcmp(arg, "--test-bitmap")) {
461 test_bitmap_walk(&revs);
462 return 0;
463 }
434ea3cd
JK
464 if (skip_prefix(arg, "--progress=", &arg)) {
465 show_progress = arg;
466 continue;
467 }
caf3827e
JH
468
469 if (skip_prefix(arg, ("--" CL_ARG__FILTER "="), &arg)) {
470 parse_list_objects_filter(&filter_options, arg);
471 if (filter_options.choice && !revs.blob_objects)
472 die(_("object filtering requires --objects"));
caf3827e
JH
473 continue;
474 }
f4371a88 475 if (!strcmp(arg, ("--no-" CL_ARG__FILTER))) {
aa57b871 476 list_objects_filter_set_no_filter(&filter_options);
f4371a88
JH
477 continue;
478 }
caf3827e
JH
479 if (!strcmp(arg, "--filter-print-omitted")) {
480 arg_print_omitted = 1;
481 continue;
482 }
483
df11e196
JT
484 if (!strcmp(arg, "--exclude-promisor-objects"))
485 continue; /* already handled above */
486 if (skip_prefix(arg, "--missing=", &arg))
487 continue; /* already handled above */
caf3827e 488
42357b4e
ES
489 if (!strcmp(arg, ("--no-object-names"))) {
490 arg_show_object_names = 0;
491 continue;
492 }
493
494 if (!strcmp(arg, ("--object-names"))) {
495 arg_show_object_names = 1;
496 continue;
497 }
498
ae563542 499 usage(rev_list_usage);
a6f68d47 500
fcfda02b 501 }
7594c4b2
JH
502 if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
503 /* The command line has a --pretty */
d797257e 504 info.hdr_termination = '\n';
7594c4b2 505 if (revs.commit_format == CMIT_FMT_ONELINE)
d797257e 506 info.header_prefix = "";
7594c4b2 507 else
d797257e 508 info.header_prefix = "commit ";
7594c4b2 509 }
db89665f
JH
510 else if (revs.verbose_header)
511 /* Only --header was specified */
512 revs.commit_format = CMIT_FMT_RAW;
fcfda02b 513
7f97de5e 514 if ((!revs.commits && reflog_walk_empty(revs.reflog_info) &&
c01499ef 515 (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
0159ba32 516 !revs.pending.nr) &&
a12cbe23 517 !revs.rev_input_given && !revs.read_from_stdin) ||
8c1f0b44 518 revs.diff)
7b34c2fa
LT
519 usage(rev_list_usage);
520
2aea7a51
JK
521 if (revs.show_notes)
522 die(_("rev-list does not support display of notes"));
523
caf3827e
JH
524 if (filter_options.choice && use_bitmap_index)
525 die(_("cannot combine --use-bitmap-index with object filtering"));
526
80235ba7
JH
527 save_commit_buffer = (revs.verbose_header ||
528 revs.grep_filter.pattern_list ||
529 revs.grep_filter.header_list);
4e1dc640
JH
530 if (bisect_list)
531 revs.limited = 1;
9181ca2c 532
434ea3cd 533 if (show_progress)
8aade107 534 progress = start_delayed_progress(show_progress, 0);
434ea3cd 535
c8a70d35 536 if (use_bitmap_index && !revs.prune) {
aa32939f
VM
537 if (revs.count && !revs.left_right && !revs.cherry_mark) {
538 uint32_t commit_count;
5c9f9bf3 539 int max_count = revs.max_count;
3ae5fa07
JT
540 struct bitmap_index *bitmap_git;
541 if ((bitmap_git = prepare_bitmap_walk(&revs))) {
542 count_bitmap_commit_list(bitmap_git, &commit_count, NULL, NULL, NULL);
5c9f9bf3
JK
543 if (max_count >= 0 && max_count < commit_count)
544 commit_count = max_count;
aa32939f 545 printf("%d\n", commit_count);
f3c23db2 546 free_bitmap_index(bitmap_git);
aa32939f
VM
547 return 0;
548 }
fb85db84
JK
549 } else if (revs.max_count < 0 &&
550 revs.tag_objects && revs.tree_objects && revs.blob_objects) {
3ae5fa07
JT
551 struct bitmap_index *bitmap_git;
552 if ((bitmap_git = prepare_bitmap_walk(&revs))) {
553 traverse_bitmap_commit_list(bitmap_git, &show_object_fast);
f3c23db2 554 free_bitmap_index(bitmap_git);
aa32939f
VM
555 return 0;
556 }
557 }
558 }
559
3d51e1b5
MK
560 if (prepare_revision_walk(&revs))
561 die("revision walk setup failed");
a4a88b2b 562 if (revs.tree_objects)
4f6d26b1 563 mark_edges_uninteresting(&revs, show_edge, 0);
a4a88b2b 564
457f08a0 565 if (bisect_list) {
156e1782 566 int reaches, all;
457f08a0 567
24d707f6 568 find_bisection(&revs.commits, &reaches, &all, bisect_find_all);
95188648 569
9996983c 570 if (bisect_show_vars)
13858e57 571 return show_bisect_vars(&info, reaches, all);
457f08a0 572 }
7b34c2fa 573
caf3827e
JH
574 if (arg_print_omitted)
575 oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE);
576 if (arg_missing_action == MA_PRINT)
577 oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
578
579 traverse_commit_list_filtered(
580 &filter_options, &revs, show_commit, show_object, &info,
581 (arg_print_omitted ? &omitted_objects : NULL));
582
583 if (arg_print_omitted) {
584 struct oidset_iter iter;
585 struct object_id *oid;
586 oidset_iter_init(&omitted_objects, &iter);
587 while ((oid = oidset_iter_next(&iter)))
588 printf("~%s\n", oid_to_hex(oid));
589 oidset_clear(&omitted_objects);
590 }
591 if (arg_missing_action == MA_PRINT) {
592 struct oidset_iter iter;
593 struct object_id *oid;
594 oidset_iter_init(&missing_objects, &iter);
595 while ((oid = oidset_iter_next(&iter)))
596 printf("?%s\n", oid_to_hex(oid));
597 oidset_clear(&missing_objects);
598 }
8906300f 599
434ea3cd
JK
600 stop_progress(&progress);
601
f69c5018 602 if (revs.count) {
b388e14b
MG
603 if (revs.left_right && revs.cherry_mark)
604 printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
605 else if (revs.left_right)
f69c5018 606 printf("%d\t%d\n", revs.count_left, revs.count_right);
b388e14b
MG
607 else if (revs.cherry_mark)
608 printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
f69c5018
TR
609 else
610 printf("%d\n", revs.count_left + revs.count_right);
611 }
612
64745109
LT
613 return 0;
614}