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