blob: ff5a38372d76cc50167a8f7e7862a67cc9d419ea [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"
Linus Torvalds5fb61b82006-05-18 14:19:20 -07006#include "builtin.h"
Christian Couder50e62a82007-10-22 07:47:56 +02007#include "log-tree.h"
Adam Simpkins7fefda52008-05-04 03:36:54 -07008#include "graph.h"
Christian Coudera2ad79c2009-03-26 05:55:24 +01009#include "bisect.h"
Linus Torvalds89063002005-05-30 18:46:32 -070010
Linus Torvaldsa6f68d42005-05-25 18:29:09 -070011static const char rev_list_usage[] =
Stephan Beyer1b1dd232008-07-13 15:36:15 +020012"git rev-list [OPTION] <commit-id>... [ -- paths... ]\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080013" limiting output:\n"
Štěpán Němec62b46982010-10-08 19:31:15 +020014" --max-count=<n>\n"
15" --max-age=<epoch>\n"
16" --min-age=<epoch>\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080017" --sparse\n"
18" --no-merges\n"
Michael J Gruberad5aeed2011-03-21 11:14:06 +010019" --min-parents=<n>\n"
20" --no-min-parents\n"
21" --max-parents=<n>\n"
22" --no-max-parents\n"
Junio C Hamano93b74bc2006-01-27 01:39:24 -080023" --remove-empty\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080024" --all\n"
Uwe Kleine-Königa5aa9302008-02-28 08:24:25 +010025" --branches\n"
26" --tags\n"
27" --remotes\n"
Junio C Hamano42cabc32006-09-05 21:39:02 -070028" --stdin\n"
Shawn O. Pearce27350892007-11-11 02:29:41 -050029" --quiet\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080030" ordering output:\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080031" --topo-order\n"
Junio C Hamano4c8725f2006-02-15 22:05:33 -080032" --date-order\n"
Kevin Ballard7ccd3662008-03-19 02:16:28 -040033" --reverse\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080034" formatting output:\n"
35" --parents\n"
Junio C Hamano72276a32008-04-03 23:01:47 -070036" --children\n"
Junio C Hamanoc6496572006-02-19 03:32:31 -080037" --objects | --objects-edge\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080038" --unpacked\n"
39" --header | --pretty\n"
Štěpán Němec62b46982010-10-08 19:31:15 +020040" --abbrev=<n> | --no-abbrev\n"
Junio C Hamano5c51c982006-04-06 21:32:36 -070041" --abbrev-commit\n"
Brian Gernhardtb24bace2007-04-05 10:53:07 -040042" --left-right\n"
Junio C Hamano69e0c252005-10-30 01:03:45 -080043" special purpose:\n"
Junio C Hamano457f08a2007-03-21 22:15:54 -070044" --bisect\n"
Christian Couder50e62a82007-10-22 07:47:56 +020045" --bisect-vars\n"
46" --bisect-all"
Junio C Hamano69e0c252005-10-30 01:03:45 -080047;
Linus Torvaldsa6f68d42005-05-25 18:29:09 -070048
Christian Couder11c211f2009-04-06 21:28:36 +020049static void finish_commit(struct commit *commit, void *data);
50static void show_commit(struct commit *commit, void *data)
Linus Torvalds81f2bb12005-06-02 09:19:53 -070051{
Christian Couderd7972572009-04-06 22:28:00 +020052 struct rev_list_info *info = data;
53 struct rev_info *revs = info->revs;
Christian Couder11c211f2009-04-06 21:28:36 +020054
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +070055 if (info->flags & REV_LIST_QUIET) {
56 finish_commit(commit, data);
57 return;
58 }
59
Christian Couder11c211f2009-04-06 21:28:36 +020060 graph_show_commit(revs->graph);
Adam Simpkins7fefda52008-05-04 03:36:54 -070061
Thomas Rastf69c5012010-06-10 13:47:23 +020062 if (revs->count) {
Michael J Gruberb388e142011-04-26 10:24:29 +020063 if (commit->object.flags & PATCHSAME)
64 revs->count_same++;
65 else if (commit->object.flags & SYMMETRIC_LEFT)
Thomas Rastf69c5012010-06-10 13:47:23 +020066 revs->count_left++;
67 else
68 revs->count_right++;
69 finish_commit(commit, data);
70 return;
71 }
72
Christian Couderd7972572009-04-06 22:28:00 +020073 if (info->show_timestamp)
Junio C Hamanodc68c4f2006-03-22 00:22:00 -080074 printf("%lu ", commit->date);
Christian Couderd7972572009-04-06 22:28:00 +020075 if (info->header_prefix)
76 fputs(info->header_prefix, stdout);
Adam Simpkins7528f272008-05-25 00:07:21 -070077
Michael J Gruber1df2d652011-03-07 13:31:39 +010078 if (!revs->graph)
79 fputs(get_revision_mark(revs, commit), stdout);
Christian Couder11c211f2009-04-06 21:28:36 +020080 if (revs->abbrev_commit && revs->abbrev)
81 fputs(find_unique_abbrev(commit->object.sha1, revs->abbrev),
Junio C Hamano7594c4b2006-04-15 23:48:27 -070082 stdout);
Junio C Hamano5c51c982006-04-06 21:32:36 -070083 else
84 fputs(sha1_to_hex(commit->object.sha1), stdout);
Christian Couder11c211f2009-04-06 21:28:36 +020085 if (revs->print_parents) {
Linus Torvalds81f2bb12005-06-02 09:19:53 -070086 struct commit_list *parents = commit->parents;
87 while (parents) {
Junio C Hamano1ed84152007-07-08 19:05:31 -070088 printf(" %s", sha1_to_hex(parents->item->object.sha1));
Linus Torvalds81f2bb12005-06-02 09:19:53 -070089 parents = parents->next;
90 }
91 }
Christian Couder11c211f2009-04-06 21:28:36 +020092 if (revs->children.name) {
Junio C Hamano72276a32008-04-03 23:01:47 -070093 struct commit_list *children;
94
Christian Couder11c211f2009-04-06 21:28:36 +020095 children = lookup_decoration(&revs->children, &commit->object);
Junio C Hamano72276a32008-04-03 23:01:47 -070096 while (children) {
97 printf(" %s", sha1_to_hex(children->item->object.sha1));
98 children = children->next;
99 }
100 }
Christian Couder11c211f2009-04-06 21:28:36 +0200101 show_decorations(revs, commit);
102 if (revs->commit_format == CMIT_FMT_ONELINE)
Junio C Hamanod87449c2005-08-08 22:15:40 -0700103 putchar(' ');
104 else
105 putchar('\n');
106
Christian Couder11c211f2009-04-06 21:28:36 +0200107 if (revs->verbose_header && commit->buffer) {
Brandon Caseyf285a2d2008-10-09 14:12:12 -0500108 struct strbuf buf = STRBUF_INIT;
Thomas Rastdd2e7942009-10-19 17:48:08 +0200109 struct pretty_print_context ctx = {0};
110 ctx.abbrev = revs->abbrev;
111 ctx.date_mode = revs->date_mode;
Jeff Kingf026c752012-05-04 01:25:18 -0400112 ctx.date_mode_explicit = revs->date_mode_explicit;
Jeff King6bf13942011-05-26 18:27:49 -0400113 ctx.fmt = revs->commit_format;
114 pretty_print_commit(&ctx, commit, &buf);
Christian Couder11c211f2009-04-06 21:28:36 +0200115 if (revs->graph) {
Adam Simpkins7fefda52008-05-04 03:36:54 -0700116 if (buf.len) {
Christian Couder11c211f2009-04-06 21:28:36 +0200117 if (revs->commit_format != CMIT_FMT_ONELINE)
118 graph_show_oneline(revs->graph);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700119
Christian Couder11c211f2009-04-06 21:28:36 +0200120 graph_show_commit_msg(revs->graph, &buf);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700121
122 /*
123 * Add a newline after the commit message.
124 *
125 * Usually, this newline produces a blank
126 * padding line between entries, in which case
127 * we need to add graph padding on this line.
128 *
129 * However, the commit message may not end in a
130 * newline. In this case the newline simply
131 * ends the last line of the commit message,
132 * and we don't need any graph output. (This
133 * always happens with CMIT_FMT_ONELINE, and it
134 * happens with CMIT_FMT_USERFORMAT when the
135 * format doesn't explicitly end in a newline.)
136 */
137 if (buf.len && buf.buf[buf.len - 1] == '\n')
Christian Couder11c211f2009-04-06 21:28:36 +0200138 graph_show_padding(revs->graph);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700139 putchar('\n');
140 } else {
141 /*
142 * If the message buffer is empty, just show
143 * the rest of the graph output for this
144 * commit.
145 */
Christian Couder11c211f2009-04-06 21:28:36 +0200146 if (graph_show_remainder(revs->graph))
Adam Simpkins7fefda52008-05-04 03:36:54 -0700147 putchar('\n');
Erik Faye-Lund1fb5fdd2010-03-21 15:40:16 +0100148 if (revs->commit_format == CMIT_FMT_ONELINE)
149 putchar('\n');
Adam Simpkins7fefda52008-05-04 03:36:54 -0700150 }
151 } else {
Erik Faye-Lund1fb5fdd2010-03-21 15:40:16 +0100152 if (revs->commit_format != CMIT_FMT_USERFORMAT ||
Jeff King9130ac92010-10-07 14:25:43 -0400153 buf.len) {
154 fwrite(buf.buf, 1, buf.len, stdout);
155 putchar(info->hdr_termination);
156 }
Adam Simpkins7fefda52008-05-04 03:36:54 -0700157 }
Pierre Habouzit674d1722007-09-10 12:35:06 +0200158 strbuf_release(&buf);
Adam Simpkins7fefda52008-05-04 03:36:54 -0700159 } else {
Christian Couder11c211f2009-04-06 21:28:36 +0200160 if (graph_show_remainder(revs->graph))
Adam Simpkins7fefda52008-05-04 03:36:54 -0700161 putchar('\n');
Linus Torvalds7620d392005-07-04 16:36:48 -0700162 }
Theodore Ts'o06f59e92007-06-29 13:40:46 -0400163 maybe_flush_or_die(stdout, "stdout");
Christian Couder11c211f2009-04-06 21:28:36 +0200164 finish_commit(commit, data);
Shawn O. Pearce27350892007-11-11 02:29:41 -0500165}
166
Christian Couder11c211f2009-04-06 21:28:36 +0200167static void finish_commit(struct commit *commit, void *data)
Shawn O. Pearce27350892007-11-11 02:29:41 -0500168{
Linus Torvaldscb115742006-06-17 18:47:58 -0700169 if (commit->parents) {
170 free_commit_list(commit->parents);
171 commit->parents = NULL;
172 }
Junio C Hamano4cac42b2006-08-27 21:19:39 -0700173 free(commit->buffer);
174 commit->buffer = NULL;
jon@blackcubes.dyndns.orga3437b82005-06-06 15:39:40 +0000175}
176
Junio C Hamano49473672011-09-01 15:43:33 -0700177static void finish_object(struct object *obj,
178 const struct name_path *path, const char *name,
179 void *cb_data)
Shawn O. Pearce27350892007-11-11 02:29:41 -0500180{
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700181 struct rev_list_info *info = cb_data;
Linus Torvalds8d2dfc42009-04-10 17:27:58 -0700182 if (obj->type == OBJ_BLOB && !has_sha1_file(obj->sha1))
183 die("missing blob object '%s'", sha1_to_hex(obj->sha1));
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700184 if (info->revs->verify_objects && !obj->parsed && obj->type != OBJ_COMMIT)
185 parse_object(obj->sha1);
Shawn O. Pearce27350892007-11-11 02:29:41 -0500186}
187
Junio C Hamano49473672011-09-01 15:43:33 -0700188static void show_object(struct object *obj,
189 const struct name_path *path, const char *component,
190 void *cb_data)
Linus Torvalds9de48752005-06-24 22:56:58 -0700191{
Clemens Buchachercb8da702012-02-13 21:17:11 +0100192 struct rev_list_info *info = cb_data;
Junio C Hamano49473672011-09-01 15:43:33 -0700193 finish_object(obj, path, component, cb_data);
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700194 if (info->flags & REV_LIST_QUIET)
195 return;
Junio C Hamano91f17512011-08-17 14:30:34 -0700196 show_object_with_name(stdout, obj, path, component);
Linus Torvalds9de48752005-06-24 22:56:58 -0700197}
198
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700199static void show_edge(struct commit *commit)
200{
201 printf("-%s\n", sha1_to_hex(commit->object.sha1));
202}
203
Christian Couder9f199b12009-02-21 09:26:01 +0100204static inline int log2i(int n)
205{
206 int log2 = 0;
207
208 for (; n > 1; n >>= 1)
209 log2++;
210
211 return log2;
212}
213
214static inline int exp2i(int n)
215{
216 return 1 << n;
217}
218
219/*
220 * Estimate the number of bisect steps left (after the current step)
221 *
222 * For any x between 0 included and 2^n excluded, the probability for
223 * n - 1 steps left looks like:
224 *
225 * P(2^n + x) == (2^n - x) / (2^n + x)
226 *
227 * and P(2^n + x) < 0.5 means 2^n < 3x
228 */
Christian Couder1c876542009-04-19 11:55:38 +0200229int estimate_bisect_steps(int all)
Christian Couder9f199b12009-02-21 09:26:01 +0100230{
231 int n, x, e;
232
233 if (all < 3)
234 return 0;
235
236 n = log2i(all);
237 e = exp2i(n);
238 x = all - e;
239
240 return (e < 3 * x) ? n : n - 1;
241}
242
Christian Couder280e65c2009-04-19 11:55:43 +0200243void print_commit_list(struct commit_list *list,
244 const char *format_cur,
245 const char *format_last)
246{
247 for ( ; list; list = list->next) {
248 const char *format = list->next ? format_cur : format_last;
249 printf(format, sha1_to_hex(list->item->object.sha1));
250 }
251}
252
Christian Couder38ef7502009-04-21 07:54:10 +0200253static void print_var_str(const char *var, const char *val)
Christian Couder280e65c2009-04-19 11:55:43 +0200254{
Christian Couder38ef7502009-04-21 07:54:10 +0200255 printf("%s='%s'\n", var, val);
Christian Couder280e65c2009-04-19 11:55:43 +0200256}
257
Christian Couder38ef7502009-04-21 07:54:10 +0200258static void print_var_int(const char *var, int val)
Christian Couder280e65c2009-04-19 11:55:43 +0200259{
Christian Couder38ef7502009-04-21 07:54:10 +0200260 printf("%s=%d\n", var, val);
Christian Couder280e65c2009-04-19 11:55:43 +0200261}
262
Junio C Hamanof1c92c62010-01-11 22:21:18 -0800263static int show_bisect_vars(struct rev_list_info *info, int reaches, int all)
Christian Couder99969832009-03-26 05:55:30 +0100264{
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700265 int cnt, flags = info->flags;
Christian Couder280e65c2009-04-19 11:55:43 +0200266 char hex[41] = "";
Christian Couder95188642009-03-26 05:55:49 +0100267 struct commit_list *tried;
Christian Couderd7972572009-04-06 22:28:00 +0200268 struct rev_info *revs = info->revs;
Christian Couder99969832009-03-26 05:55:30 +0100269
Nguyễn Thái Ngọc Duy8ba8fe02012-02-28 20:59:59 +0700270 if (!revs->commits)
Christian Couder99969832009-03-26 05:55:30 +0100271 return 1;
272
Christian Couder9af35892009-06-06 06:41:33 +0200273 revs->commits = filter_skipped(revs->commits, &tried,
274 flags & BISECT_SHOW_ALL,
275 NULL, NULL);
Christian Couder95188642009-03-26 05:55:49 +0100276
Christian Couder99969832009-03-26 05:55:30 +0100277 /*
Christian Couder7428d752009-03-26 05:55:41 +0100278 * revs->commits can reach "reaches" commits among
Christian Couder99969832009-03-26 05:55:30 +0100279 * "all" commits. If it is good, then there are
280 * (all-reaches) commits left to be bisected.
281 * On the other hand, if it is bad, then the set
282 * to bisect is "reaches".
283 * A bisect set of size N has (N-1) commits further
284 * to test, as we already know one bad one.
285 */
286 cnt = all - reaches;
287 if (cnt < reaches)
288 cnt = reaches;
Christian Couder6a17fad2009-03-26 05:55:35 +0100289
Christian Couder95188642009-03-26 05:55:49 +0100290 if (revs->commits)
291 strcpy(hex, sha1_to_hex(revs->commits->item->object.sha1));
Christian Couder99969832009-03-26 05:55:30 +0100292
Christian Couder37c4c382009-03-29 11:55:43 +0200293 if (flags & BISECT_SHOW_ALL) {
Christian Couderd7972572009-04-06 22:28:00 +0200294 traverse_commit_list(revs, show_commit, show_object, info);
Christian Couder99969832009-03-26 05:55:30 +0100295 printf("------\n");
296 }
297
Christian Couder38ef7502009-04-21 07:54:10 +0200298 print_var_str("bisect_rev", hex);
299 print_var_int("bisect_nr", cnt - 1);
300 print_var_int("bisect_good", all - reaches - 1);
301 print_var_int("bisect_bad", reaches - 1);
302 print_var_int("bisect_all", all);
303 print_var_int("bisect_steps", estimate_bisect_steps(all));
Christian Couder99969832009-03-26 05:55:30 +0100304
305 return 0;
306}
307
Linus Torvaldsa633fca2006-07-28 22:44:25 -0700308int cmd_rev_list(int argc, const char **argv, const char *prefix)
Linus Torvalds64745102005-04-23 19:04:40 -0700309{
Christian Couder11c211f2009-04-06 21:28:36 +0200310 struct rev_info revs;
Christian Couderd7972572009-04-06 22:28:00 +0200311 struct rev_list_info info;
Linus Torvaldsd9a83682006-02-27 08:54:36 -0800312 int i;
Christian Couderff62d732009-03-26 05:55:17 +0100313 int bisect_list = 0;
Junio C Hamano457f08a2007-03-21 22:15:54 -0700314 int bisect_show_vars = 0;
Christian Couder50e62a82007-10-22 07:47:56 +0200315 int bisect_find_all = 0;
Linus Torvalds64745102005-04-23 19:04:40 -0700316
Johannes Schindelinef90d6d2008-05-14 18:46:53 +0100317 git_config(git_default_config, NULL);
Linus Torvaldsa633fca2006-07-28 22:44:25 -0700318 init_revisions(&revs, prefix);
Michael J Gruber7337b132010-03-22 14:36:30 +0100319 revs.abbrev = DEFAULT_ABBREV;
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700320 revs.commit_format = CMIT_FMT_UNSPECIFIED;
Linus Torvaldsa4a88b22006-02-28 11:24:00 -0800321 argc = setup_revisions(argc, argv, &revs, NULL);
Linus Torvaldsae563542006-02-25 16:19:46 -0800322
Christian Couderd7972572009-04-06 22:28:00 +0200323 memset(&info, 0, sizeof(info));
324 info.revs = &revs;
Linus Torvaldsad3f9a72009-10-27 11:28:07 -0700325 if (revs.bisect)
326 bisect_list = 1;
Christian Couderd7972572009-04-06 22:28:00 +0200327
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700328 if (DIFF_OPT_TST(&revs.diffopt, QUICK))
329 info.flags |= REV_LIST_QUIET;
Kay Sieversfcfda022005-05-06 10:00:11 +0200330 for (i = 1 ; i < argc; i++) {
Linus Torvaldscf484542005-10-20 21:25:09 -0700331 const char *arg = argv[i];
Kay Sieversfcfda022005-05-06 10:00:11 +0200332
Linus Torvaldsa6f68d42005-05-25 18:29:09 -0700333 if (!strcmp(arg, "--header")) {
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700334 revs.verbose_header = 1;
Linus Torvalds9d97aa62005-06-01 08:42:22 -0700335 continue;
336 }
Junio C Hamanodc68c4f2006-03-22 00:22:00 -0800337 if (!strcmp(arg, "--timestamp")) {
Christian Couderd7972572009-04-06 22:28:00 +0200338 info.show_timestamp = 1;
Junio C Hamanodc68c4f2006-03-22 00:22:00 -0800339 continue;
340 }
Linus Torvalds8b3a1e02005-06-17 22:54:50 -0700341 if (!strcmp(arg, "--bisect")) {
342 bisect_list = 1;
343 continue;
344 }
Christian Couder50e62a82007-10-22 07:47:56 +0200345 if (!strcmp(arg, "--bisect-all")) {
346 bisect_list = 1;
347 bisect_find_all = 1;
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700348 info.flags |= BISECT_SHOW_ALL;
Christian Couder6e46cc02009-02-08 15:54:47 +0100349 revs.show_decorations = 1;
Christian Couder50e62a82007-10-22 07:47:56 +0200350 continue;
351 }
Junio C Hamano457f08a2007-03-21 22:15:54 -0700352 if (!strcmp(arg, "--bisect-vars")) {
353 bisect_list = 1;
354 bisect_show_vars = 1;
355 continue;
356 }
Linus Torvalds7b34c2f2005-10-25 15:24:55 -0700357 usage(rev_list_usage);
358
Linus Torvalds7b34c2f2005-10-25 15:24:55 -0700359 }
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700360 if (revs.commit_format != CMIT_FMT_UNSPECIFIED) {
361 /* The command line has a --pretty */
Christian Couderd7972572009-04-06 22:28:00 +0200362 info.hdr_termination = '\n';
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700363 if (revs.commit_format == CMIT_FMT_ONELINE)
Christian Couderd7972572009-04-06 22:28:00 +0200364 info.header_prefix = "";
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700365 else
Christian Couderd7972572009-04-06 22:28:00 +0200366 info.header_prefix = "commit ";
Junio C Hamano7594c4b2006-04-15 23:48:27 -0700367 }
Junio C Hamanodb896652006-04-17 12:42:36 -0700368 else if (revs.verbose_header)
369 /* Only --header was specified */
370 revs.commit_format = CMIT_FMT_RAW;
Linus Torvalds7b34c2f2005-10-25 15:24:55 -0700371
Christian Couderd7972572009-04-06 22:28:00 +0200372 if ((!revs.commits &&
Junio C Hamano8c1f0b42006-04-14 22:43:34 -0700373 (!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
Linus Torvalds1f1e8952006-06-19 17:42:35 -0700374 !revs.pending.nr)) ||
Junio C Hamano8c1f0b42006-04-14 22:43:34 -0700375 revs.diff)
Linus Torvaldsae563542006-02-25 16:19:46 -0800376 usage(rev_list_usage);
377
Junio C Hamano80235ba2010-01-17 20:09:06 -0800378 save_commit_buffer = (revs.verbose_header ||
379 revs.grep_filter.pattern_list ||
380 revs.grep_filter.header_list);
Junio C Hamano4e1dc642006-04-14 15:57:32 -0700381 if (bisect_list)
382 revs.limited = 1;
Junio C Hamano9181ca22006-03-28 17:28:04 -0800383
Martin Koegler3d51e1b2008-02-18 08:31:56 +0100384 if (prepare_revision_walk(&revs))
385 die("revision walk setup failed");
Linus Torvaldsa4a88b22006-02-28 11:24:00 -0800386 if (revs.tree_objects)
Junio C Hamano8d1d8f82006-09-06 01:42:23 -0700387 mark_edges_uninteresting(revs.commits, &revs, show_edge);
Linus Torvaldsa4a88b22006-02-28 11:24:00 -0800388
Junio C Hamano457f08a2007-03-21 22:15:54 -0700389 if (bisect_list) {
390 int reaches = reaches, all = all;
391
Christian Couder50e62a82007-10-22 07:47:56 +0200392 revs.commits = find_bisection(revs.commits, &reaches, &all,
393 bisect_find_all);
Christian Couder95188642009-03-26 05:55:49 +0100394
Christian Couder99969832009-03-26 05:55:30 +0100395 if (bisect_show_vars)
Christian Couder13858e52009-04-07 05:08:42 +0200396 return show_bisect_vars(&info, reaches, all);
Junio C Hamano457f08a2007-03-21 22:15:54 -0700397 }
Linus Torvaldsae563542006-02-25 16:19:46 -0800398
Nguyễn Thái Ngọc Duy98993722012-02-28 21:00:00 +0700399 traverse_commit_list(&revs, show_commit, show_object, &info);
Linus Torvalds89063002005-05-30 18:46:32 -0700400
Thomas Rastf69c5012010-06-10 13:47:23 +0200401 if (revs.count) {
Michael J Gruberb388e142011-04-26 10:24:29 +0200402 if (revs.left_right && revs.cherry_mark)
403 printf("%d\t%d\t%d\n", revs.count_left, revs.count_right, revs.count_same);
404 else if (revs.left_right)
Thomas Rastf69c5012010-06-10 13:47:23 +0200405 printf("%d\t%d\n", revs.count_left, revs.count_right);
Michael J Gruberb388e142011-04-26 10:24:29 +0200406 else if (revs.cherry_mark)
407 printf("%d\t%d\n", revs.count_left + revs.count_right, revs.count_same);
Thomas Rastf69c5012010-06-10 13:47:23 +0200408 else
409 printf("%d\n", revs.count_left + revs.count_right);
410 }
411
Linus Torvalds64745102005-04-23 19:04:40 -0700412 return 0;
413}