summaryrefslogtreecommitdiff
path: root/builtin-rev-list.c
diff options
context:
space:
mode:
authorChristian Couder <chriscool@tuxfamily.org>2009-03-26 05:55:30 +0100
committerJunio C Hamano <gitster@pobox.com>2009-03-30 01:22:54 -0700
commit9996983c9c35353f352ef7c1abd9b3d2fbb21114 (patch)
treed515d9a42c3d4d3dc62f3abab029335e433f7e5a /builtin-rev-list.c
parenta2ad79ced25e1b76fabec079549f521e8071ddd1 (diff)
downloadgit-9996983c9c35353f352ef7c1abd9b3d2fbb21114.tar.gz
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>
Diffstat (limited to 'builtin-rev-list.c')
-rw-r--r--builtin-rev-list.c83
1 files changed, 45 insertions, 38 deletions
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index b1e8200d2b..74d22b4658 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -226,6 +226,49 @@ static int estimate_bisect_steps(int all)
return (e < 3 * x) ? n : n - 1;
}
+static int show_bisect_vars(int reaches, int all, int bisect_find_all)
+{
+ int cnt;
+ char hex[41];
+
+ if (!revs.commits)
+ return 1;
+
+ /*
+ * revs.commits can reach "reaches" commits among
+ * "all" commits. If it is good, then there are
+ * (all-reaches) commits left to be bisected.
+ * On the other hand, if it is bad, then the set
+ * to bisect is "reaches".
+ * A bisect set of size N has (N-1) commits further
+ * to test, as we already know one bad one.
+ */
+ cnt = all - reaches;
+ if (cnt < reaches)
+ cnt = reaches;
+ strcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));
+
+ if (bisect_find_all) {
+ traverse_commit_list(&revs, show_commit, show_object);
+ printf("------\n");
+ }
+
+ printf("bisect_rev=%s\n"
+ "bisect_nr=%d\n"
+ "bisect_good=%d\n"
+ "bisect_bad=%d\n"
+ "bisect_all=%d\n"
+ "bisect_steps=%d\n",
+ hex,
+ cnt - 1,
+ all - reaches - 1,
+ reaches - 1,
+ all,
+ estimate_bisect_steps(all));
+
+ return 0;
+}
+
int cmd_rev_list(int argc, const char **argv, const char *prefix)
{
struct commit_list *list;
@@ -313,44 +356,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
revs.commits = find_bisection(revs.commits, &reaches, &all,
bisect_find_all);
- if (bisect_show_vars) {
- int cnt;
- char hex[41];
- if (!revs.commits)
- return 1;
- /*
- * revs.commits can reach "reaches" commits among
- * "all" commits. If it is good, then there are
- * (all-reaches) commits left to be bisected.
- * On the other hand, if it is bad, then the set
- * to bisect is "reaches".
- * A bisect set of size N has (N-1) commits further
- * to test, as we already know one bad one.
- */
- cnt = all - reaches;
- if (cnt < reaches)
- cnt = reaches;
- strcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));
-
- if (bisect_find_all) {
- traverse_commit_list(&revs, show_commit, show_object);
- printf("------\n");
- }
-
- printf("bisect_rev=%s\n"
- "bisect_nr=%d\n"
- "bisect_good=%d\n"
- "bisect_bad=%d\n"
- "bisect_all=%d\n"
- "bisect_steps=%d\n",
- hex,
- cnt - 1,
- all - reaches - 1,
- reaches - 1,
- all,
- estimate_bisect_steps(all));
- return 0;
- }
+ if (bisect_show_vars)
+ return show_bisect_vars(reaches, all, bisect_find_all);
}
traverse_commit_list(&revs,