blob: 7ae255862aaa43fb20969b75d9e434902ec2cba1 [file] [log] [blame]
Linus Torvalds64745102005-04-23 19:04:40 -07001#include "cache.h"
2#include "commit.h"
Junio C Hamanoc4e05b12006-04-10 18:14:54 -07003#include "diff.h"
Linus Torvaldsae563542006-02-25 16:19:46 -08004#include "revision.h"
Junio C Hamanoc64ed702006-09-04 21:50:12 -07005#include "list-objects.h"
Vicent Martiaa329392013-12-21 09:00:12 -05006#include "pack.h"
7#include "pack-bitmap.h"
Linus Torvalds5fb61b82006-05-18 14:19:20 -07008#include "builtin.h"
Christian Couder50e62a82007-10-22 07:47:56 +02009#include "log-tree.h"
Adam Simpkins7fefda52008-05-04 03:36:54 -070010#include "graph.h"
Christian Coudera2ad79c2009-03-26 05:55:24 +010011#include "bisect.h"
Linus Torvalds89063002005-05-30 18:46:32 -070012
Linus Torvaldsa6f68d42005-05-25 18:29:09 -070013static const char rev_list_usage[] =
Stephan Beyer1b1dd232008-07-13 15:36:15 +020014"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080015" limiting output:\n"
Štěpán Němec62b46982010-10-08 19:31:15 +020016" --max-count=<n>\n"
17" --max-age=<epoch>\n"
18" --min-age=<epoch>\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080019" --sparse\n"
20" --no-merges\n"
Michael J Gruberad5aeed2011-03-21 11:14:06 +010021" --min-parents=<n>\n"
22" --no-min-parents\n"
23" --max-parents=<n>\n"
24" --no-max-parents\n"
Junio C Hamano93b74bc2006-01-27 01:39:24 -080025" --remove-empty\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080026" --all\n"
Uwe Kleine-Königa5aa9302008-02-28 08:24:25 +010027" --branches\n"
28" --tags\n"
29" --remotes\n"
Junio C Hamano42cabc32006-09-05 21:39:02 -070030" --stdin\n"
Shawn O. Pearce27350892007-11-11 02:29:41 -050031" --quiet\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080032" ordering output:\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080033" --topo-order\n"
Junio C Hamano4c8725f2006-02-15 22:05:33 -080034" --date-order\n"
Kevin Ballard7ccd3662008-03-19 02:16:28 -040035" --reverse\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080036" formatting output:\n"
37" --parents\n"
Junio C Hamano72276a32008-04-03 23:01:47 -070038" --children\n"
Junio C Hamanoc6496572006-02-19 03:32:31 -080039" --objects | --objects-edge\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080040" --unpacked\n"
41" --header | --pretty\n"
Štěpán Němec62b46982010-10-08 19:31:15 +020042" --abbrev=<n> | --no-abbrev\n"
Junio C Hamano5c51c982006-04-06 21:32:36 -070043" --abbrev-commit\n"
Brian Gernhardtb24bace2007-04-05 10:53:07 -040044" --left-right\n"
Lawrence Siebert75d2e5a2015-07-01 02:24:11 -070045" --count\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080046" special purpose:\n"
Junio C Hamano457f08a2007-03-21 22:15:54 -070047" --bisect\n"
Christian Couder50e62a82007-10-22 07:47:56 +020048" --bisect-vars\n"
49" --bisect-all"
Junio C Hamano69e0c252005-10-30 01:03:45 -080050;
Linus Torvaldsa6f68d42005-05-25 18:29:09 -070051
Christian Couder11c211f2009-04-06 21:28:36 +020052static void finish_commit(struct commit *commit, void *data);
53static void show_commit(struct commit *commit, void *data)
Linus Torvalds81f2bb12005-06-02 09:19:53 -070054{
Christian Couderd7972572009-04-06 22:28:00 +020055 struct rev_list_info *info = data;
56 struct rev_info *revs = info->revs;
Christian Couder11c211f2009-04-06 21:28:36 +020057
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +070058 if (info->flags & REV_LIST_QUIET) {
59 finish_commit(commit, data);
60 return;
61 }
62
Christian Couder11c211f2009-04-06 21:28:36 +020063 graph_show_commit(revs->graph);
Adam Simpkins7fefda52008-05-04 03:36:54 -070064
Thomas Rastf69c5012010-06-10 13:47:23 +020065 if (revs->count) {
Michael J Gruberb388e142011-04-26 10:24:29 +020066 if (commit->object.flags & PATCHSAME)
67 revs->count_same++;
68 else if (commit->object.flags & SYMMETRIC_LEFT)
Thomas Rastf69c5012010-06-10 13:47:23 +020069 revs->count_left++;
70 else
71 revs->count_right++;
72 finish_commit(commit, data);
73 return;
74 }
75
Christian Couderd7972572009-04-06 22:28:00 +020076 if (info->show_timestamp)
Junio C Hamanodc68c4f2006-03-22 00:22:00 -080077 printf("%lu ", commit->date);
Christian Couderd7972572009-04-06 22:28:00 +020078 if (info->header_prefix)
79 fputs(info->header_prefix, stdout);
Adam Simpkins7528f272008-05-25 00:07:21 -070080
Michael J Gruber1df2d652011-03-07 13:31:39 +010081 if (!revs->graph)
82 fputs(get_revision_mark(revs, commit), stdout);
Christian Couder11c211f2009-04-06 21:28:36 +020083 if (revs->abbrev_commit && revs->abbrev)
84 fputs(find_unique_abbrev(commit->object.sha1, revs->abbrev),
Junio C Hamano7594c4b2006-04-15 23:48:27 -070085 stdout);
Junio C Hamano5c51c982006-04-06 21:32:36 -070086 else
87 fputs(sha1_to_hex(commit->object.sha1), stdout);
Christian Couder11c211f2009-04-06 21:28:36 +020088 if (revs->print_parents) {
Linus Torvalds81f2bb12005-06-02 09:19:53 -070089 struct commit_list *parents = commit->parents;
90 while (parents) {
Junio C Hamano1ed84152007-07-08 19:05:31 -070091 printf(" %s", sha1_to_hex(parents->item->object.sha1));
Linus Torvalds81f2bb12005-06-02 09:19:53 -070092 parents = parents->next;
93 }
94 }
Christian Couder11c211f2009-04-06 21:28:36 +020095 if (revs->children.name) {
Junio C Hamano72276a32008-04-03 23:01:47 -070096 struct commit_list *children;
97
Christian Couder11c211f2009-04-06 21:28:36 +020098 children = lookup_decoration(&revs->children, &commit->object);
Junio C Hamano72276a32008-04-03 23:01:47 -070099 while (children) {
100 printf(" %s", sha1_to_hex(children->item->object.sha1));
101 children = children->next;
102 }
103 }
Christian Couder11c211f2009-04-06 21:28:36 +0200104 show_decorations(revs, commit);
105 if (revs->commit_format == CMIT_FMT_ONELINE)
Junio C Hamanod87449c2005-08-08 22:15:40 -0700106 putchar(' ');
107 else
108 putchar('\n');
109
Jeff King8597ea32014-06-10 17:44:13 -0400110 if (revs->verbose_header && get_cached_commit_buffer(commit, NULL)) {
Brandon Caseyf285a2d2008-10-09 14:12:12 -0500111 struct strbuf buf = STRBUF_INIT;
Thomas Rastdd2e7942009-10-19 17:48:08 +0200112 struct pretty_print_context ctx = {0};
113 ctx.abbrev = revs->abbrev;
114 ctx.date_mode = revs->date_mode;
Jeff Kingf026c752012-05-04 01:25:18 -0400115 ctx.date_mode_explicit = revs->date_mode_explicit;
Jeff King6bf13942011-05-26 18:27:49 -0400116 ctx.fmt = revs->commit_format;
Alexey Shumkinecaee802013-06-26 14:19:50 +0400117 ctx.output_encoding = get_log_output_encoding();
Jeff King6bf13942011-05-26 18:27:49 -0400118 pretty_print_commit(&ctx, commit, &buf);
Christian Couder11c211f2009-04-06 21:28:36 +0200119 if (revs->graph) {
Adam Simpkins7fefda52008-05-04 03:36:54 -0700120 if (buf.len) {
Christian Couder11c211f2009-04-06 21:28:36 +0200121 if (revs->commit_format != CMIT_FMT_ONELINE)
122 graph_show_oneline(revs->graph);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700123
Christian Couder11c211f2009-04-06 21:28:36 +0200124 graph_show_commit_msg(revs->graph, &buf);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700125
126 /*
127 * Add a newline after the commit message.
128 *
129 * Usually, this newline produces a blank
130 * padding line between entries, in which case
131 * we need to add graph padding on this line.
132 *
133 * However, the commit message may not end in a
134 * newline. In this case the newline simply
135 * ends the last line of the commit message,
136 * and we don't need any graph output. (This
137 * always happens with CMIT_FMT_ONELINE, and it
138 * happens with CMIT_FMT_USERFORMAT when the
139 * format doesn't explicitly end in a newline.)
140 */
141 if (buf.len && buf.buf[buf.len - 1] == '\n')
Christian Couder11c211f2009-04-06 21:28:36 +0200142 graph_show_padding(revs->graph);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700143 putchar('\n');
144 } else {
145 /*
146 * If the message buffer is empty, just show
147 * the rest of the graph output for this
148 * commit.
149 */
Christian Couder11c211f2009-04-06 21:28:36 +0200150 if (graph_show_remainder(revs->graph))
Adam Simpkins7fefda52008-05-04 03:36:54 -0700151 putchar('\n');
Erik Faye-Lund1fb5fdd2010-03-21 15:40:16 +0100152 if (revs->commit_format == CMIT_FMT_ONELINE)
153 putchar('\n');
Adam Simpkins7fefda52008-05-04 03:36:54 -0700154 }
155 } else {
Erik Faye-Lund1fb5fdd2010-03-21 15:40:16 +0100156 if (revs->commit_format != CMIT_FMT_USERFORMAT ||
Jeff King9130ac92010-10-07 14:25:43 -0400157 buf.len) {
158 fwrite(buf.buf, 1, buf.len, stdout);
159 putchar(info->hdr_termination);
160 }
Adam Simpkins7fefda52008-05-04 03:36:54 -0700161 }
Pierre Habouzit674d1722007-09-10 12:35:06 +0200162 strbuf_release(&buf);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700163 } else {
Christian Couder11c211f2009-04-06 21:28:36 +0200164 if (graph_show_remainder(revs->graph))
Adam Simpkins7fefda52008-05-04 03:36:54 -0700165 putchar('\n');
Linus Torvalds7620d392005-07-04 16:36:48 -0700166 }
Theodore Ts'o06f59e92007-06-29 13:40:46 -0400167 maybe_flush_or_die(stdout, "stdout");
Christian Couder11c211f2009-04-06 21:28:36 +0200168 finish_commit(commit, data);
Shawn O. Pearce27350892007-11-11 02:29:41 -0500169}
170
Christian Couder11c211f2009-04-06 21:28:36 +0200171static void finish_commit(struct commit *commit, void *data)
Shawn O. Pearce27350892007-11-11 02:29:41 -0500172{
Linus Torvaldscb115742006-06-17 18:47:58 -0700173 if (commit->parents) {
174 free_commit_list(commit->parents);
175 commit->parents = NULL;
176 }
Jeff King0fb370d2014-06-12 18:05:37 -0400177 free_commit_buffer(commit);
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:40 +0000178}
179
Jeff King2824e182016-02-11 17:28:36 -0500180static void finish_object(struct object *obj, const char *name, void *cb_data)
Shawn O. Pearce27350892007-11-11 02:29:41 -0500181{
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700182 struct rev_list_info *info = cb_data;
Linus Torvalds8d2dfc42009-04-10 17:27:58 -0700183 if (obj->type == OBJ_BLOB && !has_sha1_file(obj->sha1))
184 die("missing blob object '%s'", sha1_to_hex(obj->sha1));
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700185 if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
186 parse_object(obj->sha1);
Shawn O. Pearce27350892007-11-11 02:29:41 -0500187}
188
Jeff King2824e182016-02-11 17:28:36 -0500189static void show_object(struct object *obj, const char *name, void *cb_data)
Linus Torvalds9de48752005-06-24 22:56:58 -0700190{
Clemens Buchachercb8da702012-02-13 21:17:11 +0100191 struct rev_list_info *info = cb_data;
Jeff King2824e182016-02-11 17:28:36 -0500192 finish_object(obj, name, cb_data);
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700193 if (info->flags & REV_LIST_QUIET)
194 return;
Jeff King2824e182016-02-11 17:28:36 -0500195 show_object_with_name(stdout, obj, name);
Linus Torvalds9de48752005-06-24 22:56:58 -0700196}
197
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700198static void show_edge(struct commit *commit)
199{
200 printf("-%s\n", sha1_to_hex(commit->object.sha1));
201}
202
Christian Couder38ef7502009-04-21 07:54:10 +0200203static void print_var_str(const char *var, const char *val)
Christian Couder280e65c2009-04-19 11:55:43 +0200204{
Christian Couder38ef7502009-04-21 07:54:10 +0200205 printf("%s='%s'\n", var, val);
Christian Couder280e65c2009-04-19 11:55:43 +0200206}
207
Christian Couder38ef7502009-04-21 07:54:10 +0200208static void print_var_int(const char *var, int val)
Christian Couder280e65c2009-04-19 11:55:43 +0200209{
Christian Couder38ef7502009-04-21 07:54:10 +0200210 printf("%s=%d\n", var, val);
Christian Couder280e65c2009-04-19 11:55:43 +0200211}
212
Junio C Hamanof1c92c62010-01-11 22:21:18 -0800213static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
Christian Couder99969832009-03-26 05:55:30 +0100214{
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700215 int cnt, flags = info->flags;
Christian Couder280e65c2009-04-19 11:55:43 +0200216 char hex[41] = "";
Christian Couder95188642009-03-26 05:55:49 +0100217 struct commit_list *tried;
Christian Couderd7972572009-04-06 22:28:00 +0200218 struct rev_info *revs = info->revs;
Christian Couder99969832009-03-26 05:55:30 +0100219
Nguyễn Thái Ngọc Duy8ba8fe02012-02-28 20:59:59 +0700220 if (!revs->commits)
Christian Couder99969832009-03-26 05:55:30 +0100221 return 1;
222
Christian Couder9af35892009-06-06 06:41:33 +0200223 revs->commits = filter_skipped(revs->commits, &tried,
224 flags & BISECT_SHOW_ALL,
225 NULL, NULL);
Christian Couder95188642009-03-26 05:55:49 +0100226
Christian Couder99969832009-03-26 05:55:30 +0100227 /*
Christian Couder7428d752009-03-26 05:55:41 +0100228 * revs->commits can reach "reaches" commits among
Christian Couder99969832009-03-26 05:55:30 +0100229 * "all" commits. If it is good, then there are
230 * (all-reaches) commits left to be bisected.
231 * On the other hand, if it is bad, then the set
232 * to bisect is "reaches".
233 * A bisect set of size N has (N-1) commits further
234 * to test, as we already know one bad one.
235 */
236 cnt = all - reaches;
237 if (cnt < reaches)
238 cnt = reaches;
Christian Couder6a17fad2009-03-26 05:55:35 +0100239
Christian Couder95188642009-03-26 05:55:49 +0100240 if (revs->commits)
241 strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
Christian Couder99969832009-03-26 05:55:30 +0100242
Christian Couder37c4c382009-03-29 11:55:43 +0200243 if (flags & BISECT_SHOW_ALL) {
Christian Couderd7972572009-04-06 22:28:00 +0200244 traverse_commit_list(revs, show_commit, show_object, info);
Christian Couder99969832009-03-26 05:55:30 +0100245 printf("------\n");
246 }
247
Christian Couder38ef7502009-04-21 07:54:10 +0200248 print_var_str("bisect_rev", hex);
249 print_var_int("bisect_nr", cnt - 1);
250 print_var_int("bisect_good", all - reaches - 1);
251 print_var_int("bisect_bad", reaches - 1);
252 print_var_int("bisect_all", all);
253 print_var_int("bisect_steps", estimate_bisect_steps(all));
Christian Couder99969832009-03-26 05:55:30 +0100254
255 return 0;
256}
257
Vicent Martiaa329392013-12-21 09:00:12 -0500258static int show_object_fast(
259 const unsigned char *sha1,
260 enum object_type type,
261 int exclude,
262 uint32_t name_hash,
263 struct packed_git *found_pack,
264 off_t found_offset)
265{
266 fprintf(stdout, "%s\n", sha1_to_hex(sha1));
267 return 1;
268}
269
Linus Torvaldsa633fca2006-07-28 22:44:25 -0700270int cmd_rev_list(int argc, const char **argv, const char *prefix)
Linus Torvalds64745102005-04-23 19:04:40 -0700271{
Christian Couder11c211f2009-04-06 21:28:36 +0200272 struct rev_info revs;
Christian Couderd7972572009-04-06 22:28:00 +0200273 struct rev_list_info info;
Linus Torvaldsd9a83682006-02-27 08:54:36 -0800274 int i;
Christian Couderff62d732009-03-26 05:55:17 +0100275 int bisect_list = 0;
Junio C Hamano457f08a2007-03-21 22:15:54 -0700276 int bisect_show_vars = 0;
Christian Couder50e62a82007-10-22 07:47:56 +0200277 int bisect_find_all = 0;
Vicent Martiaa329392013-12-21 09:00:12 -0500278 int use_bitmap_index = 0;
Linus Torvalds64745102005-04-23 19:04:40 -0700279
Johannes Schindelinef90d6d2008-05-14 18:46:53 +0100280 git_config(git_default_config, NULL);
Linus Torvaldsa633fca2006-07-28 22:44:25 -0700281 init_revisions(&revs, prefix);
Michael J Gruber7337b132010-03-22 14:36:30 +0100282 revs.abbrev = DEFAULT_ABBREV;
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700283 revs.commit_format = CMIT_FMT_UNSPECIFIED;
Linus Torvaldsa4a88b22006-02-28 11:24:00 -0800284 argc = setup_revisions(argc, argv, &revs, NULL);
Linus Torvaldsae563542006-02-25 16:19:46 -0800285
Christian Couderd7972572009-04-06 22:28:00 +0200286 memset(&info, 0, sizeof(info));
287 info.revs = &revs;
Linus Torvaldsad3f9a72009-10-27 11:28:07 -0700288 if (revs.bisect)
289 bisect_list = 1;
Christian Couderd7972572009-04-06 22:28:00 +0200290
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700291 if (DIFF_OPT_TST(&revs.diffopt, QUICK))
292 info.flags |= REV_LIST_QUIET;
Kay Sieversfcfda022005-05-06 10:00:11 +0200293 for (i = 1 ; i < argc; i++) {
Linus Torvaldscf484542005-10-20 21:25:09 -0700294 const char *arg = argv[i];
Kay Sieversfcfda022005-05-06 10:00:11 +0200295
Linus Torvaldsa6f68d42005-05-25 18:29:09 -0700296 if (!strcmp(arg, "--header")) {
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700297 revs.verbose_header = 1;
Linus Torvalds9d97aa62005-06-01 08:42:22 -0700298 continue;
299 }
Junio C Hamanodc68c4f2006-03-22 00:22:00 -0800300 if (!strcmp(arg, "--timestamp")) {
Christian Couderd7972572009-04-06 22:28:00 +0200301 info.show_timestamp = 1;
Junio C Hamanodc68c4f2006-03-22 00:22:00 -0800302 continue;
303 }
Linus Torvalds8b3a1e02005-06-17 22:54:50 -0700304 if (!strcmp(arg, "--bisect")) {
305 bisect_list = 1;
306 continue;
307 }
Christian Couder50e62a82007-10-22 07:47:56 +0200308 if (!strcmp(arg, "--bisect-all")) {
309 bisect_list = 1;
310 bisect_find_all = 1;
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700311 info.flags |= BISECT_SHOW_ALL;
Christian Couder6e46cc02009-02-08 15:54:47 +0100312 revs.show_decorations = 1;
Christian Couder50e62a82007-10-22 07:47:56 +0200313 continue;
314 }
Junio C Hamano457f08a2007-03-21 22:15:54 -0700315 if (!strcmp(arg, "--bisect-vars")) {
316 bisect_list = 1;
317 bisect_show_vars = 1;
318 continue;
319 }
Vicent Martiaa329392013-12-21 09:00:12 -0500320 if (!strcmp(arg, "--use-bitmap-index")) {
321 use_bitmap_index = 1;
322 continue;
323 }
324 if (!strcmp(arg, "--test-bitmap")) {
325 test_bitmap_walk(&revs);
326 return 0;
327 }
Linus Torvalds7b34c2f2005-10-25 15:24:55 -0700328 usage(rev_list_usage);
329
Linus Torvalds7b34c2f2005-10-25 15:24:55 -0700330 }
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700331 if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
332 /* The command line has a --pretty */
Christian Couderd7972572009-04-06 22:28:00 +0200333 info.hdr_termination = '\n';
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700334 if (revs.commit_format == CMIT_FMT_ONELINE)
Christian Couderd7972572009-04-06 22:28:00 +0200335 info.header_prefix = "";
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700336 else
Christian Couderd7972572009-04-06 22:28:00 +0200337 info.header_prefix = "commit ";
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700338 }
Junio C Hamanodb896652006-04-17 12:42:36 -0700339 else if (revs.verbose_header)
340 /* Only --header was specified */
341 revs.commit_format = CMIT_FMT_RAW;
Linus Torvalds7b34c2f2005-10-25 15:24:55 -0700342
Christian Couderd7972572009-04-06 22:28:00 +0200343 if ((!revs.commits &&
Junio C Hamanoc01499e2013-10-16 10:26:39 -0700344 (!(revs.tag_objects || revs.tree_objects || revs.blob_objects) &&
Linus Torvalds1f1e8952006-06-19 17:42:35 -0700345 !revs.pending.nr)) ||
Junio C Hamano8c1f0b42006-04-14 22:43:34 -0700346 revs.diff)
Linus Torvaldsae563542006-02-25 16:19:46 -0800347 usage(rev_list_usage);
348
Junio C Hamano80235ba2010-01-17 20:09:06 -0800349 save_commit_buffer = (revs.verbose_header ||
350 revs.grep_filter.pattern_list ||
351 revs.grep_filter.header_list);
Junio C Hamano4e1dc642006-04-14 15:57:32 -0700352 if (bisect_list)
353 revs.limited = 1;
Junio C Hamano9181ca22006-03-28 17:28:04 -0800354
Jeff Kingc8a70d32015-07-01 14:42:17 -0400355 if (use_bitmap_index && !revs.prune) {
Vicent Martiaa329392013-12-21 09:00:12 -0500356 if (revs.count && !revs.left_right && !revs.cherry_mark) {
357 uint32_t commit_count;
358 if (!prepare_bitmap_walk(&revs)) {
359 count_bitmap_commit_list(&commit_count, NULL, NULL, NULL);
360 printf("%d\n", commit_count);
361 return 0;
362 }
363 } else if (revs.tag_objects && revs.tree_objects && revs.blob_objects) {
364 if (!prepare_bitmap_walk(&revs)) {
365 traverse_bitmap_commit_list(&show_object_fast);
366 return 0;
367 }
368 }
369 }
370
Martin Koegler3d51e1b2008-02-18 08:31:56 +0100371 if (prepare_revision_walk(&revs))
372 die("revision walk setup failed");
Linus Torvaldsa4a88b22006-02-28 11:24:00 -0800373 if (revs.tree_objects)
Nguyễn Thái Ngọc Duye76a5fb2013-08-16 16:52:06 +0700374 mark_edges_uninteresting(&revs, show_edge);
Linus Torvaldsa4a88b22006-02-28 11:24:00 -0800375
Junio C Hamano457f08a2007-03-21 22:15:54 -0700376 if (bisect_list) {
377 int reaches = reaches, all = all;
378
Christian Couder50e62a82007-10-22 07:47:56 +0200379 revs.commits = find_bisection(revs.commits, &reaches, &all,
380 bisect_find_all);
Christian Couder95188642009-03-26 05:55:49 +0100381
Christian Couder99969832009-03-26 05:55:30 +0100382 if (bisect_show_vars)
Christian Couder13858e52009-04-07 05:08:42 +0200383 return show_bisect_vars(&info, reaches, all);
Junio C Hamano457f08a2007-03-21 22:15:54 -0700384 }
Linus Torvaldsae563542006-02-25 16:19:46 -0800385
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700386 traverse_commit_list(&revs, show_commit, show_object, &info);
Linus Torvalds89063002005-05-30 18:46:32 -0700387
Thomas Rastf69c5012010-06-10 13:47:23 +0200388 if (revs.count) {
Michael J Gruberb388e142011-04-26 10:24:29 +0200389 if (revs.left_right && revs.cherry_mark)
390 printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
391 else if (revs.left_right)
Thomas Rastf69c5012010-06-10 13:47:23 +0200392 printf("%d\t%d\n", revs.count_left, revs.count_right);
Michael J Gruberb388e142011-04-26 10:24:29 +0200393 else if (revs.cherry_mark)
394 printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
Thomas Rastf69c5012010-06-10 13:47:23 +0200395 else
396 printf("%d\n", revs.count_left + revs.count_right);
397 }
398
Linus Torvalds64745102005-04-23 19:04:40 -0700399 return 0;
400}