rev-list: move code to show bisect vars into its own function
This is a straightforward clean up to make "cmd_rev_list" function smaller. Signed-off-by: Christian Couder <chriscool@tuxfamily.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Christian Couder committed
Mar 26, 2009 at 05:55 UTC
9996983c9c35353f352ef7c1abd9b3d2fbb21114
1 file changed
+45
-38
builtin-rev-list.c
+45
-38
@@ -226,6 +226,49 @@ static int estimate_bisect_steps(int all)
226
return (e < 3 * x) ? n : n - 1;
227
}
228
229
+static int show_bisect_vars(int reaches, int all, int bisect_find_all)
230
+{
231
+ int cnt;
232
+ char hex[41];
233
+
234
+ if (!revs.commits)
235
+ return 1;
236
+
237
+ /*
238
+ * revs.commits can reach "reaches" commits among
239
+ * "all" commits. If it is good, then there are
240
+ * (all-reaches) commits left to be bisected.
241
+ * On the other hand, if it is bad, then the set
242
+ * to bisect is "reaches".
243
+ * A bisect set of size N has (N-1) commits further
244
+ * to test, as we already know one bad one.
245
+ */
246
+ cnt = all - reaches;
247
+ if (cnt < reaches)
248
+ cnt = reaches;
249
+ strcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));
250
+
251
+ if (bisect_find_all) {
252
+ traverse_commit_list(&revs, show_commit, show_object);
253
+ printf("------\n");
254
+ }
255
+
256
+ printf("bisect_rev=%s\n"
257
+ "bisect_nr=%d\n"
258
+ "bisect_good=%d\n"
259
+ "bisect_bad=%d\n"
260
+ "bisect_all=%d\n"
261
+ "bisect_steps=%d\n",
262
+ hex,
263
+ cnt - 1,
264
+ all - reaches - 1,
265
+ reaches - 1,
266
+ all,
267
+ estimate_bisect_steps(all));
268
+
269
+ return 0;
270
+}
271
+
272
int cmd_rev_list(int argc, const char **argv, const char *prefix)
273
{
274
struct commit_list *list;
@@ -313,44 +356,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
356
357
revs.commits = find_bisection(revs.commits, &reaches, &all,
358
bisect_find_all);
316
- if (bisect_show_vars) {
317
- int cnt;
318
- char hex[41];
319
- if (!revs.commits)
320
- return 1;
321
- /*
322
- * revs.commits can reach "reaches" commits among
323
- * "all" commits. If it is good, then there are
324
- * (all-reaches) commits left to be bisected.
325
- * On the other hand, if it is bad, then the set
326
- * to bisect is "reaches".
327
- * A bisect set of size N has (N-1) commits further
328
- * to test, as we already know one bad one.
329
- */
330
- cnt = all - reaches;
331
- if (cnt < reaches)
332
- cnt = reaches;
333
- strcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));
334
-
335
- if (bisect_find_all) {
336
- traverse_commit_list(&revs, show_commit, show_object);
337
- printf("------\n");
338
- }
339
-
340
- printf("bisect_rev=%s\n"
341
- "bisect_nr=%d\n"
342
- "bisect_good=%d\n"
343
- "bisect_bad=%d\n"
344
- "bisect_all=%d\n"
345
- "bisect_steps=%d\n",
346
- hex,
347
- cnt - 1,
348
- all - reaches - 1,
349
- reaches - 1,
350
- all,
351
- estimate_bisect_steps(all));
352
- return 0;
353
- }
359
+ if (bisect_show_vars)
360
+ return show_bisect_vars(reaches, all, bisect_find_all);
361
}
362
363
traverse_commit_list(&revs,