]> git.ipfire.org Git - thirdparty/git.git/blame - builtin/rev-list.c
Merge branch 'es/add-doc-list-short-form-of-all-in-synopsis'
[thirdparty/git.git] / builtin / rev-list.c
CommitLineData
bc5c5ec0 1#include "builtin.h"
b2141fc1 2#include "config.h"
64745109 3#include "commit.h"
c4e05b1a 4#include "diff.h"
32a8f510 5#include "environment.h"
f394e093 6#include "gettext.h"
41771fa4 7#include "hex.h"
ae563542 8#include "revision.h"
c64ed70d 9#include "list-objects.h"
caf3827e
JH
10#include "list-objects-filter.h"
11#include "list-objects-filter-options.h"
7c0fe330 12#include "object.h"
dabab1d6 13#include "object-name.h"
87bed179 14#include "object-file.h"
a034e910 15#include "object-store-ll.h"
aa32939f
VM
16#include "pack.h"
17#include "pack-bitmap.h"
50e62a8e 18#include "log-tree.h"
7fefda5c 19#include "graph.h"
a2ad79ce 20#include "bisect.h"
434ea3cd 21#include "progress.h"
7f97de5e 22#include "reflog-walk.h"
caf3827e 23#include "oidset.h"
df11e196 24#include "packfile.h"
8906300f 25
a6f68d47 26static const char rev_list_usage[] =
c08cfc39 27"git rev-list [<options>] <commit>... [--] [<path>...]\n"
acf7828e 28"\n"
69e0c256 29" limiting output:\n"
62b4698e
ŠN
30" --max-count=<n>\n"
31" --max-age=<epoch>\n"
32" --min-age=<epoch>\n"
69e0c256
JH
33" --sparse\n"
34" --no-merges\n"
ad5aeede
MG
35" --min-parents=<n>\n"
36" --no-min-parents\n"
37" --max-parents=<n>\n"
38" --no-max-parents\n"
93b74bca 39" --remove-empty\n"
69e0c256 40" --all\n"
a5aa930d
UKK
41" --branches\n"
42" --tags\n"
43" --remotes\n"
42cabc34 44" --stdin\n"
c6ce27ab 45" --exclude-hidden=[fetch|receive|uploadpack]\n"
27350891 46" --quiet\n"
69e0c256 47" ordering output:\n"
69e0c256 48" --topo-order\n"
4c8725f1 49" --date-order\n"
7ccd3667 50" --reverse\n"
69e0c256
JH
51" formatting output:\n"
52" --parents\n"
72276a3e 53" --children\n"
c6496575 54" --objects | --objects-edge\n"
9096451a 55" --disk-usage[=human]\n"
69e0c256
JH
56" --unpacked\n"
57" --header | --pretty\n"
42357b4e 58" --[no-]object-names\n"
62b4698e 59" --abbrev=<n> | --no-abbrev\n"
5c51c985 60" --abbrev-commit\n"
b24bace5 61" --left-right\n"
75d2e5a7 62" --count\n"
69e0c256 63" special purpose:\n"
457f08a0 64" --bisect\n"
50e62a8e
CC
65" --bisect-vars\n"
66" --bisect-all"
69e0c256 67;
a6f68d47 68
434ea3cd
JK
69static struct progress *progress;
70static unsigned progress_counter;
71
caf3827e
JH
72static struct oidset omitted_objects;
73static int arg_print_omitted; /* print objects omitted by filter */
74
75static struct oidset missing_objects;
76enum missing_action {
77 MA_ERROR = 0, /* fail if any missing objects are encountered */
78 MA_ALLOW_ANY, /* silently allow ALL missing objects */
79 MA_PRINT, /* print ALL missing objects in special section */
df11e196 80 MA_ALLOW_PROMISOR, /* silently allow all missing PROMISOR objects */
caf3827e
JH
81};
82static enum missing_action arg_missing_action;
83
42357b4e
ES
84/* display only the oid of each object encountered */
85static int arg_show_object_names = 1;
86
caf3827e
JH
87#define DEFAULT_OIDSET_SIZE (16*1024)
88
16950f83
JK
89static int show_disk_usage;
90static off_t total_disk_usage;
9096451a 91static int human_readable;
16950f83
JK
92
93static off_t get_object_disk_usage(struct object *obj)
94{
95 off_t size;
96 struct object_info oi = OBJECT_INFO_INIT;
97 oi.disk_sizep = &size;
98 if (oid_object_info_extended(the_repository, &obj->oid, &oi, 0) < 0)
99 die(_("unable to get disk usage of %s"), oid_to_hex(&obj->oid));
100 return size;
101}
102
b4952923
KN
103static inline void finish_object__ma(struct object *obj)
104{
105 /*
106 * Whether or not we try to dynamically fetch missing objects
107 * from the server, we currently DO NOT have the object. We
108 * can either print, allow (ignore), or conditionally allow
109 * (ignore) them.
110 */
111 switch (arg_missing_action) {
112 case MA_ERROR:
113 die("missing %s object '%s'",
114 type_name(obj->type), oid_to_hex(&obj->oid));
115 return;
116
117 case MA_ALLOW_ANY:
118 return;
119
120 case MA_PRINT:
121 oidset_insert(&missing_objects, &obj->oid);
122 return;
123
124 case MA_ALLOW_PROMISOR:
125 if (is_promisor_object(&obj->oid))
126 return;
127 die("unexpected missing %s object '%s'",
128 type_name(obj->type), oid_to_hex(&obj->oid));
129 return;
130
131 default:
132 BUG("unhandled missing_action");
133 return;
134 }
135}
136
137static void finish_commit(struct commit *commit)
138{
139 free_commit_list(commit->parents);
140 commit->parents = NULL;
141 free_commit_buffer(the_repository->parsed_objects,
142 commit);
143}
144
11c211fa 145static void show_commit(struct commit *commit, void *data)
81f2bb1f 146{
d797257e
CC
147 struct rev_list_info *info = data;
148 struct rev_info *revs = info->revs;
11c211fa 149
434ea3cd
JK
150 display_progress(progress, ++progress_counter);
151
9830926c
KN
152 if (revs->do_not_die_on_missing_objects &&
153 oidset_contains(&revs->missing_commits, &commit->object.oid)) {
154 finish_object__ma(&commit->object);
155 return;
156 }
157
16950f83
JK
158 if (show_disk_usage)
159 total_disk_usage += get_object_disk_usage(&commit->object);
160
98993722 161 if (info->flags & REV_LIST_QUIET) {
d92349dd 162 finish_commit(commit);
98993722
NTND
163 return;
164 }
165
11c211fa 166 graph_show_commit(revs->graph);
7fefda5c 167
f69c5018 168 if (revs->count) {
b388e14b
MG
169 if (commit->object.flags & PATCHSAME)
170 revs->count_same++;
171 else if (commit->object.flags & SYMMETRIC_LEFT)
f69c5018
TR
172 revs->count_left++;
173 else
174 revs->count_right++;
d92349dd 175 finish_commit(commit);
f69c5018
TR
176 return;
177 }
178
d797257e 179 if (info->show_timestamp)
cb71f8bd 180 printf("%"PRItime" ", commit->date);
d797257e
CC
181 if (info->header_prefix)
182 fputs(info->header_prefix, stdout);
7528f27d 183
d1c5ae78 184 if (revs->include_header) {
185 if (!revs->graph)
186 fputs(get_revision_mark(revs, commit), stdout);
187 if (revs->abbrev_commit && revs->abbrev)
d850b7a5 188 fputs(repo_find_unique_abbrev(the_repository, &commit->object.oid, revs->abbrev),
d1c5ae78 189 stdout);
190 else
191 fputs(oid_to_hex(&commit->object.oid), stdout);
192 }
11c211fa 193 if (revs->print_parents) {
81f2bb1f
LT
194 struct commit_list *parents = commit->parents;
195 while (parents) {
f2fd0760 196 printf(" %s", oid_to_hex(&parents->item->object.oid));
81f2bb1f
LT
197 parents = parents->next;
198 }
199 }
11c211fa 200 if (revs->children.name) {
72276a3e
JH
201 struct commit_list *children;
202
11c211fa 203 children = lookup_decoration(&revs->children, &commit->object);
72276a3e 204 while (children) {
f2fd0760 205 printf(" %s", oid_to_hex(&children->item->object.oid));
72276a3e
JH
206 children = children->next;
207 }
208 }
11c211fa
CC
209 show_decorations(revs, commit);
210 if (revs->commit_format == CMIT_FMT_ONELINE)
d87449c5 211 putchar(' ');
d1c5ae78 212 else if (revs->include_header)
d87449c5
JH
213 putchar('\n');
214
7fa31b64 215 if (revs->verbose_header) {
f285a2d7 216 struct strbuf buf = STRBUF_INIT;
dd2e794a
TR
217 struct pretty_print_context ctx = {0};
218 ctx.abbrev = revs->abbrev;
219 ctx.date_mode = revs->date_mode;
f026c756 220 ctx.date_mode_explicit = revs->date_mode_explicit;
6bf13944 221 ctx.fmt = revs->commit_format;
ecaee805 222 ctx.output_encoding = get_log_output_encoding();
d75dfb10 223 ctx.color = revs->diffopt.use_color;
6bf13944 224 pretty_print_commit(&ctx, commit, &buf);
660e113c
JK
225 if (buf.len) {
226 if (revs->commit_format != CMIT_FMT_ONELINE)
227 graph_show_oneline(revs->graph);
7fefda5c 228
660e113c 229 graph_show_commit_msg(revs->graph, stdout, &buf);
7fefda5c 230
660e113c
JK
231 /*
232 * Add a newline after the commit message.
233 *
234 * Usually, this newline produces a blank
235 * padding line between entries, in which case
236 * we need to add graph padding on this line.
237 *
238 * However, the commit message may not end in a
239 * newline. In this case the newline simply
240 * ends the last line of the commit message,
241 * and we don't need any graph output. (This
242 * always happens with CMIT_FMT_ONELINE, and it
243 * happens with CMIT_FMT_USERFORMAT when the
244 * format doesn't explicitly end in a newline.)
245 */
246 if (buf.len && buf.buf[buf.len - 1] == '\n')
247 graph_show_padding(revs->graph);
98985c69 248 putchar(info->hdr_termination);
7fefda5c 249 } else {
660e113c
JK
250 /*
251 * If the message buffer is empty, just show
252 * the rest of the graph output for this
253 * commit.
254 */
255 if (graph_show_remainder(revs->graph))
256 putchar('\n');
257 if (revs->commit_format == CMIT_FMT_ONELINE)
258 putchar('\n');
7fefda5c 259 }
674d1727 260 strbuf_release(&buf);
7fefda5c 261 } else {
11c211fa 262 if (graph_show_remainder(revs->graph))
7fefda5c 263 putchar('\n');
7620d39f 264 }
06f59e9f 265 maybe_flush_or_die(stdout, "stdout");
d92349dd 266 finish_commit(commit);
27350891
SP
267}
268
be252d33
JK
269static int finish_object(struct object *obj, const char *name UNUSED,
270 void *cb_data)
27350891 271{
98993722 272 struct rev_list_info *info = cb_data;
f06ab027 273 if (oid_object_info_extended(the_repository, &obj->oid, NULL, 0) < 0) {
caf3827e 274 finish_object__ma(obj);
df11e196
JT
275 return 1;
276 }
98993722 277 if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
109cd76d 278 parse_object(the_repository, &obj->oid);
df11e196 279 return 0;
27350891
SP
280}
281
de1e67d0 282static void show_object(struct object *obj, const char *name, void *cb_data)
9de48752 283{
cb8da705 284 struct rev_list_info *info = cb_data;
55cb10f9
JK
285 struct rev_info *revs = info->revs;
286
df11e196
JT
287 if (finish_object(obj, name, cb_data))
288 return;
434ea3cd 289 display_progress(progress, ++progress_counter);
16950f83
JK
290 if (show_disk_usage)
291 total_disk_usage += get_object_disk_usage(obj);
98993722
NTND
292 if (info->flags & REV_LIST_QUIET)
293 return;
55cb10f9
JK
294
295 if (revs->count) {
20a5fd88
JH
296 /*
297 * The object count is always accumulated in the .count_right
298 * field for traversal that is not a left-right traversal,
299 * and cmd_rev_list() made sure that a .count request that
300 * wants to count non-commit objects, which is handled by
301 * the show_object() callback, does not ask for .left_right.
302 */
55cb10f9
JK
303 revs->count_right++;
304 return;
305 }
306
42357b4e
ES
307 if (arg_show_object_names)
308 show_object_with_name(stdout, obj, name);
309 else
310 printf("%s\n", oid_to_hex(&obj->oid));
9de48752
LT
311}
312
8d1d8f83
JH
313static void show_edge(struct commit *commit)
314{
f2fd0760 315 printf("-%s\n", oid_to_hex(&commit->object.oid));
8d1d8f83
JH
316}
317
38ef7507 318static void print_var_str(const char *var, const char *val)
280e65cb 319{
38ef7507 320 printf("%s='%s'\n", var, val);
280e65cb
CC
321}
322
38ef7507 323static void print_var_int(const char *var, int val)
280e65cb 324{
38ef7507 325 printf("%s=%d\n", var, val);
280e65cb
CC
326}
327
f1c92c63 328static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
9996983c 329{
98993722 330 int cnt, flags = info->flags;
dc01505f 331 char hex[GIT_MAX_HEXSZ + 1] = "";
95188648 332 struct commit_list *tried;
d797257e 333 struct rev_info *revs = info->revs;
9996983c 334
8ba8fe04 335 if (!revs->commits)
9996983c
CC
336 return 1;
337
9af3589e
CC
338 revs->commits = filter_skipped(revs->commits, &tried,
339 flags & BISECT_SHOW_ALL,
340 NULL, NULL);
95188648 341
9996983c 342 /*
7428d754 343 * revs->commits can reach "reaches" commits among
9996983c
CC
344 * "all" commits. If it is good, then there are
345 * (all-reaches) commits left to be bisected.
346 * On the other hand, if it is bad, then the set
347 * to bisect is "reaches".
348 * A bisect set of size N has (N-1) commits further
349 * to test, as we already know one bad one.
350 */
351 cnt = all - reaches;
352 if (cnt < reaches)
353 cnt = reaches;
6a17fad7 354
95188648 355 if (revs->commits)
2490574d 356 oid_to_hex_r(hex, &revs->commits->item->object.oid);
9996983c 357
37c4c38d 358 if (flags & BISECT_SHOW_ALL) {
d797257e 359 traverse_commit_list(revs, show_commit, show_object, info);
9996983c
CC
360 printf("------\n");
361 }
362
38ef7507
CC
363 print_var_str("bisect_rev", hex);
364 print_var_int("bisect_nr", cnt - 1);
365 print_var_int("bisect_good", all - reaches - 1);
366 print_var_int("bisect_bad", reaches - 1);
367 print_var_int("bisect_all", all);
368 print_var_int("bisect_steps", estimate_bisect_steps(all));
9996983c
CC
369
370 return 0;
371}
372
aa32939f 373static int show_object_fast(
20664967 374 const struct object_id *oid,
c50dca2a
JK
375 enum object_type type UNUSED,
376 int exclude UNUSED,
377 uint32_t name_hash UNUSED,
378 struct packed_git *found_pack UNUSED,
379 off_t found_offset UNUSED)
aa32939f 380{
20664967 381 fprintf(stdout, "%s\n", oid_to_hex(oid));
aa32939f
VM
382 return 1;
383}
384
9096451a
LL
385static void print_disk_usage(off_t size)
386{
387 struct strbuf sb = STRBUF_INIT;
388 if (human_readable)
389 strbuf_humanise_bytes(&sb, size);
390 else
391 strbuf_addf(&sb, "%"PRIuMAX, (uintmax_t)size);
392 puts(sb.buf);
393 strbuf_release(&sb);
394}
395
caf3827e
JH
396static inline int parse_missing_action_value(const char *value)
397{
398 if (!strcmp(value, "error")) {
399 arg_missing_action = MA_ERROR;
400 return 1;
401 }
402
403 if (!strcmp(value, "allow-any")) {
404 arg_missing_action = MA_ALLOW_ANY;
df11e196 405 fetch_if_missing = 0;
caf3827e
JH
406 return 1;
407 }
408
409 if (!strcmp(value, "print")) {
410 arg_missing_action = MA_PRINT;
df11e196
JT
411 fetch_if_missing = 0;
412 return 1;
413 }
414
415 if (!strcmp(value, "allow-promisor")) {
416 arg_missing_action = MA_ALLOW_PROMISOR;
417 fetch_if_missing = 0;
caf3827e
JH
418 return 1;
419 }
420
421 return 0;
422}
423
2aaeb9ac 424static int try_bitmap_count(struct rev_info *revs,
9cf68b27 425 int filter_provided_objects)
792f8119 426{
608d9c93
JK
427 uint32_t commit_count = 0,
428 tag_count = 0,
429 tree_count = 0,
430 blob_count = 0;
792f8119
JK
431 int max_count;
432 struct bitmap_index *bitmap_git;
433
434 /* This function only handles counting, not general traversal. */
435 if (!revs->count)
436 return -1;
437
438 /*
439 * A bitmap result can't know left/right, etc, because we don't
440 * actually traverse.
441 */
442 if (revs->left_right || revs->cherry_mark)
443 return -1;
444
608d9c93
JK
445 /*
446 * If we're counting reachable objects, we can't handle a max count of
447 * commits to traverse, since we don't know which objects go with which
448 * commit.
449 */
450 if (revs->max_count >= 0 &&
451 (revs->tag_objects || revs->tree_objects || revs->blob_objects))
452 return -1;
453
792f8119
JK
454 /*
455 * This must be saved before doing any walking, since the revision
456 * machinery will count it down to zero while traversing.
457 */
458 max_count = revs->max_count;
459
09d4a79e 460 bitmap_git = prepare_bitmap_walk(revs, filter_provided_objects);
792f8119
JK
461 if (!bitmap_git)
462 return -1;
463
608d9c93
JK
464 count_bitmap_commit_list(bitmap_git, &commit_count,
465 revs->tree_objects ? &tree_count : NULL,
466 revs->blob_objects ? &blob_count : NULL,
467 revs->tag_objects ? &tag_count : NULL);
792f8119
JK
468 if (max_count >= 0 && max_count < commit_count)
469 commit_count = max_count;
470
608d9c93 471 printf("%d\n", commit_count + tree_count + blob_count + tag_count);
792f8119
JK
472 free_bitmap_index(bitmap_git);
473 return 0;
474}
475
2aaeb9ac 476static int try_bitmap_traversal(struct rev_info *revs,
9cf68b27 477 int filter_provided_objects)
792f8119
JK
478{
479 struct bitmap_index *bitmap_git;
480
481 /*
482 * We can't use a bitmap result with a traversal limit, since the set
483 * of commits we'd get would be essentially random.
484 */
485 if (revs->max_count >= 0)
486 return -1;
487
09d4a79e 488 bitmap_git = prepare_bitmap_walk(revs, filter_provided_objects);
792f8119
JK
489 if (!bitmap_git)
490 return -1;
491
4eb707eb 492 traverse_bitmap_commit_list(bitmap_git, revs, &show_object_fast);
792f8119
JK
493 free_bitmap_index(bitmap_git);
494 return 0;
495}
496
16950f83 497static int try_bitmap_disk_usage(struct rev_info *revs,
9cf68b27 498 int filter_provided_objects)
16950f83
JK
499{
500 struct bitmap_index *bitmap_git;
9096451a 501 off_t size_from_bitmap;
16950f83
JK
502
503 if (!show_disk_usage)
504 return -1;
505
09d4a79e 506 bitmap_git = prepare_bitmap_walk(revs, filter_provided_objects);
16950f83
JK
507 if (!bitmap_git)
508 return -1;
509
9096451a
LL
510 size_from_bitmap = get_disk_usage_from_bitmap(bitmap_git, revs);
511 print_disk_usage(size_from_bitmap);
16950f83
JK
512 return 0;
513}
514
a633fca0 515int cmd_rev_list(int argc, const char **argv, const char *prefix)
64745109 516{
11c211fa 517 struct rev_info revs;
d797257e 518 struct rev_list_info info;
bbcde41a
MD
519 struct setup_revision_opt s_r_opt = {
520 .allow_exclude_promisor_objects = 1,
521 };
d9a83684 522 int i;
ff62d732 523 int bisect_list = 0;
457f08a0 524 int bisect_show_vars = 0;
50e62a8e 525 int bisect_find_all = 0;
aa32939f 526 int use_bitmap_index = 0;
9cf68b27 527 int filter_provided_objects = 0;
434ea3cd 528 const char *show_progress = NULL;
0139c58a 529 int ret = 0;
64745109 530
5a88f97c
JH
531 if (argc == 2 && !strcmp(argv[1], "-h"))
532 usage(rev_list_usage);
533
ef90d6d4 534 git_config(git_default_config, NULL);
2abf3503 535 repo_init_revisions(the_repository, &revs, prefix);
7337b138 536 revs.abbrev = DEFAULT_ABBREV;
7594c4b2 537 revs.commit_format = CMIT_FMT_UNSPECIFIED;
d1c5ae78 538 revs.include_header = 1;
df11e196
JT
539
540 /*
541 * Scan the argument list before invoking setup_revisions(), so that we
542 * know if fetch_if_missing needs to be set to 0.
543 *
544 * "--exclude-promisor-objects" acts as a pre-filter on missing objects
545 * by not crossing the boundary from realized objects to promisor
546 * objects.
547 *
548 * Let "--missing" to conditionally set fetch_if_missing.
549 */
550 for (i = 1; i < argc; i++) {
551 const char *arg = argv[i];
552 if (!strcmp(arg, "--exclude-promisor-objects")) {
553 fetch_if_missing = 0;
554 revs.exclude_promisor_objects = 1;
555 break;
556 }
557 }
558 for (i = 1; i < argc; i++) {
559 const char *arg = argv[i];
560 if (skip_prefix(arg, "--missing=", &arg)) {
561 if (revs.exclude_promisor_objects)
12909b6b 562 die(_("options '%s' and '%s' cannot be used together"), "--exclude-promisor-objects", "--missing");
df11e196
JT
563 if (parse_missing_action_value(arg))
564 break;
565 }
566 }
567
ee4dfee2 568 if (arg_missing_action)
ca556f47 569 revs.do_not_die_on_missing_objects = 1;
ee4dfee2 570
bbcde41a 571 argc = setup_revisions(argc, argv, &revs, &s_r_opt);
ae563542 572
d797257e
CC
573 memset(&info, 0, sizeof(info));
574 info.revs = &revs;
ad3f9a71
LT
575 if (revs.bisect)
576 bisect_list = 1;
d797257e 577
0d1e0e78 578 if (revs.diffopt.flags.quick)
98993722 579 info.flags |= REV_LIST_QUIET;
fcfda02b 580 for (i = 1 ; i < argc; i++) {
cf484544 581 const char *arg = argv[i];
fcfda02b 582
a6f68d47 583 if (!strcmp(arg, "--header")) {
7594c4b2 584 revs.verbose_header = 1;
9d97aa64
LT
585 continue;
586 }
dc68c4ff 587 if (!strcmp(arg, "--timestamp")) {
d797257e 588 info.show_timestamp = 1;
dc68c4ff
JH
589 continue;
590 }
8b3a1e05
LT
591 if (!strcmp(arg, "--bisect")) {
592 bisect_list = 1;
593 continue;
594 }
50e62a8e
CC
595 if (!strcmp(arg, "--bisect-all")) {
596 bisect_list = 1;
597 bisect_find_all = 1;
98993722 598 info.flags |= BISECT_SHOW_ALL;
6e46cc0d 599 revs.show_decorations = 1;
50e62a8e
CC
600 continue;
601 }
457f08a0
JH
602 if (!strcmp(arg, "--bisect-vars")) {
603 bisect_list = 1;
604 bisect_show_vars = 1;
605 continue;
606 }
aa32939f
VM
607 if (!strcmp(arg, "--use-bitmap-index")) {
608 use_bitmap_index = 1;
609 continue;
610 }
611 if (!strcmp(arg, "--test-bitmap")) {
612 test_bitmap_walk(&revs);
0139c58a 613 goto cleanup;
aa32939f 614 }
434ea3cd
JK
615 if (skip_prefix(arg, "--progress=", &arg)) {
616 show_progress = arg;
617 continue;
618 }
9cf68b27
PS
619 if (!strcmp(arg, "--filter-provided-objects")) {
620 filter_provided_objects = 1;
621 continue;
622 }
caf3827e
JH
623 if (!strcmp(arg, "--filter-print-omitted")) {
624 arg_print_omitted = 1;
625 continue;
626 }
627
df11e196
JT
628 if (!strcmp(arg, "--exclude-promisor-objects"))
629 continue; /* already handled above */
630 if (skip_prefix(arg, "--missing=", &arg))
631 continue; /* already handled above */
caf3827e 632
42357b4e
ES
633 if (!strcmp(arg, ("--no-object-names"))) {
634 arg_show_object_names = 0;
635 continue;
636 }
637
638 if (!strcmp(arg, ("--object-names"))) {
639 arg_show_object_names = 1;
640 continue;
641 }
642
d1c5ae78 643 if (!strcmp(arg, ("--commit-header"))) {
644 revs.include_header = 1;
645 continue;
646 }
647
648 if (!strcmp(arg, ("--no-commit-header"))) {
649 revs.include_header = 0;
650 continue;
651 }
652
9096451a
LL
653 if (skip_prefix(arg, "--disk-usage", &arg)) {
654 if (*arg == '=') {
655 if (!strcmp(++arg, "human")) {
656 human_readable = 1;
657 } else
658 die(_("invalid value for '%s': '%s', the only allowed format is '%s'"),
659 "--disk-usage=<format>", arg, "human");
660 } else if (*arg) {
661 /*
662 * Arguably should goto a label to continue chain of ifs?
663 * Doesn't matter unless we try to add --disk-usage-foo
664 * afterwards.
665 */
666 usage(rev_list_usage);
667 }
16950f83
JK
668 show_disk_usage = 1;
669 info.flags |= REV_LIST_QUIET;
670 continue;
671 }
672
ae563542 673 usage(rev_list_usage);
a6f68d47 674
fcfda02b 675 }
d1c5ae78 676 if (revs.commit_format != CMIT_FMT_USERFORMAT)
677 revs.include_header = 1;
7594c4b2
JH
678 if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
679 /* The command line has a --pretty */
d797257e 680 info.hdr_termination = '\n';
d1c5ae78 681 if (revs.commit_format == CMIT_FMT_ONELINE || !revs.include_header)
d797257e 682 info.header_prefix = "";
7594c4b2 683 else
d797257e 684 info.header_prefix = "commit ";
7594c4b2 685 }
db89665f
JH
686 else if (revs.verbose_header)
687 /* Only --header was specified */
688 revs.commit_format = CMIT_FMT_RAW;
fcfda02b 689
7f97de5e 690 if ((!revs.commits && reflog_walk_empty(revs.reflog_info) &&
c01499ef 691 (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
0159ba32 692 !revs.pending.nr) &&
a12cbe23 693 !revs.rev_input_given && !revs.read_from_stdin) ||
8c1f0b44 694 revs.diff)
7b34c2fa
LT
695 usage(rev_list_usage);
696
2aea7a51
JK
697 if (revs.show_notes)
698 die(_("rev-list does not support display of notes"));
699
55cb10f9
JK
700 if (revs.count &&
701 (revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
702 (revs.left_right || revs.cherry_mark))
246cac85 703 die(_("marked counting and '%s' cannot be used together"), "--objects");
55cb10f9 704
80235ba7
JH
705 save_commit_buffer = (revs.verbose_header ||
706 revs.grep_filter.pattern_list ||
707 revs.grep_filter.header_list);
4e1dc640
JH
708 if (bisect_list)
709 revs.limited = 1;
9181ca2c 710
434ea3cd 711 if (show_progress)
8aade107 712 progress = start_delayed_progress(show_progress, 0);
434ea3cd 713
d90fe06e 714 if (use_bitmap_index) {
ffaa137f 715 if (!try_bitmap_count(&revs, filter_provided_objects))
0139c58a 716 goto cleanup;
ffaa137f 717 if (!try_bitmap_disk_usage(&revs, filter_provided_objects))
0139c58a 718 goto cleanup;
ffaa137f 719 if (!try_bitmap_traversal(&revs, filter_provided_objects))
0139c58a 720 goto cleanup;
aa32939f
VM
721 }
722
3d51e1b5
MK
723 if (prepare_revision_walk(&revs))
724 die("revision walk setup failed");
a4a88b2b 725 if (revs.tree_objects)
4f6d26b1 726 mark_edges_uninteresting(&revs, show_edge, 0);
a4a88b2b 727
457f08a0 728 if (bisect_list) {
156e1782 729 int reaches, all;
ad464a4e 730 unsigned bisect_flags = 0;
457f08a0 731
ad464a4e
AL
732 if (bisect_find_all)
733 bisect_flags |= FIND_BISECTION_ALL;
734
735 if (revs.first_parent_only)
736 bisect_flags |= FIND_BISECTION_FIRST_PARENT_ONLY;
737
738 find_bisection(&revs.commits, &reaches, &all, bisect_flags);
95188648 739
0139c58a
ÆAB
740 if (bisect_show_vars) {
741 ret = show_bisect_vars(&info, reaches, all);
742 goto cleanup;
743 }
457f08a0 744 }
7b34c2fa 745
9cf68b27
PS
746 if (filter_provided_objects) {
747 struct commit_list *c;
748 for (i = 0; i < revs.pending.nr; i++) {
749 struct object_array_entry *pending = revs.pending.objects + i;
750 pending->item->flags |= NOT_USER_GIVEN;
751 }
752 for (c = revs.commits; c; c = c->next)
753 c->item->object.flags |= NOT_USER_GIVEN;
754 }
755
caf3827e
JH
756 if (arg_print_omitted)
757 oidset_init(&omitted_objects, DEFAULT_OIDSET_SIZE);
758 if (arg_missing_action == MA_PRINT)
759 oidset_init(&missing_objects, DEFAULT_OIDSET_SIZE);
760
761 traverse_commit_list_filtered(
3e0370a8 762 &revs, show_commit, show_object, &info,
caf3827e
JH
763 (arg_print_omitted ? &omitted_objects : NULL));
764
765 if (arg_print_omitted) {
766 struct oidset_iter iter;
767 struct object_id *oid;
768 oidset_iter_init(&omitted_objects, &iter);
769 while ((oid = oidset_iter_next(&iter)))
770 printf("~%s\n", oid_to_hex(oid));
771 oidset_clear(&omitted_objects);
772 }
773 if (arg_missing_action == MA_PRINT) {
774 struct oidset_iter iter;
775 struct object_id *oid;
776 oidset_iter_init(&missing_objects, &iter);
777 while ((oid = oidset_iter_next(&iter)))
778 printf("?%s\n", oid_to_hex(oid));
779 oidset_clear(&missing_objects);
780 }
8906300f 781
434ea3cd
JK
782 stop_progress(&progress);
783
f69c5018 784 if (revs.count) {
b388e14b
MG
785 if (revs.left_right && revs.cherry_mark)
786 printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
787 else if (revs.left_right)
f69c5018 788 printf("%d\t%d\n", revs.count_left, revs.count_right);
b388e14b
MG
789 else if (revs.cherry_mark)
790 printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
f69c5018
TR
791 else
792 printf("%d\n", revs.count_left + revs.count_right);
793 }
794
16950f83 795 if (show_disk_usage)
9096451a 796 print_disk_usage(total_disk_usage);
16950f83 797
0139c58a
ÆAB
798cleanup:
799 release_revisions(&revs);
800 return ret;
64745109 801}