{"thread":{"id":"18558","subject":"[PATCH 04/10] rev-list: move code to show bisect vars into its own function","startedAt":"2009-03-26T04:55:30Z","lastAt":"2009-03-26T04:55:30Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":10},"messages":[{"id":"109479","messageId":"20090326055530.14425db4.chriscool@tuxfamily.org","threadId":"18558","inReplyTo":null,"subject":"[PATCH 04/10] rev-list: move code to show bisect vars into its own function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-03-26T04:55:30Z","receivedAt":"2009-03-26T04:55:30Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"This is a straightforward clean up to make \"cmd_rev_list\" function\nsmaller.\n\nSigned-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin-rev-list.c |   83 ++++++++++++++++++++++++++++------------------------\n 1 files changed, 45 insertions(+), 38 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex b1e8200..74d22b4 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -226,6 +226,49 @@ static int estimate_bisect_steps(int all)\n \treturn (e < 3 * x) ? n : n - 1;\n }\n \n+static int show_bisect_vars(int reaches, int all, int bisect_find_all)\n+{\n+\tint cnt;\n+\tchar hex[41];\n+\n+\tif (!revs.commits)\n+\t\treturn 1;\n+\n+\t/*\n+\t * revs.commits can reach \"reaches\" commits among\n+\t * \"all\" commits.  If it is good, then there are\n+\t * (all-reaches) commits left to be bisected.\n+\t * On the other hand, if it is bad, then the set\n+\t * to bisect is \"reaches\".\n+\t * A bisect set of size N has (N-1) commits further\n+\t * to test, as we already know one bad one.\n+\t */\n+\tcnt = all - reaches;\n+\tif (cnt < reaches)\n+\t\tcnt = reaches;\n+\tstrcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));\n+\n+\tif (bisect_find_all) {\n+\t\ttraverse_commit_list(&revs, show_commit, show_object);\n+\t\tprintf(\"------\\n\");\n+\t}\n+\n+\tprintf(\"bisect_rev=%s\\n\"\n+\t       \"bisect_nr=%d\\n\"\n+\t       \"bisect_good=%d\\n\"\n+\t       \"bisect_bad=%d\\n\"\n+\t       \"bisect_all=%d\\n\"\n+\t       \"bisect_steps=%d\\n\",\n+\t       hex,\n+\t       cnt - 1,\n+\t       all - reaches - 1,\n+\t       reaches - 1,\n+\t       all,\n+\t       estimate_bisect_steps(all));\n+\n+\treturn 0;\n+}\n+\n int cmd_rev_list(int argc, const char **argv, const char *prefix)\n {\n \tstruct commit_list *list;\n@@ -313,44 +356,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \n \t\trevs.commits = find_bisection(revs.commits, &reaches, &all,\n \t\t\t\t\t      bisect_find_all);\n-\t\tif (bisect_show_vars) {\n-\t\t\tint cnt;\n-\t\t\tchar hex[41];\n-\t\t\tif (!revs.commits)\n-\t\t\t\treturn 1;\n-\t\t\t/*\n-\t\t\t * revs.commits can reach \"reaches\" commits among\n-\t\t\t * \"all\" commits.  If it is good, then there are\n-\t\t\t * (all-reaches) commits left to be bisected.\n-\t\t\t * On the other hand, if it is bad, then the set\n-\t\t\t * to bisect is \"reaches\".\n-\t\t\t * A bisect set of size N has (N-1) commits further\n-\t\t\t * to test, as we already know one bad one.\n-\t\t\t */\n-\t\t\tcnt = all - reaches;\n-\t\t\tif (cnt < reaches)\n-\t\t\t\tcnt = reaches;\n-\t\t\tstrcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));\n-\n-\t\t\tif (bisect_find_all) {\n-\t\t\t\ttraverse_commit_list(&revs, show_commit, show_object);\n-\t\t\t\tprintf(\"------\\n\");\n-\t\t\t}\n-\n-\t\t\tprintf(\"bisect_rev=%s\\n\"\n-\t\t\t       \"bisect_nr=%d\\n\"\n-\t\t\t       \"bisect_good=%d\\n\"\n-\t\t\t       \"bisect_bad=%d\\n\"\n-\t\t\t       \"bisect_all=%d\\n\"\n-\t\t\t       \"bisect_steps=%d\\n\",\n-\t\t\t       hex,\n-\t\t\t       cnt - 1,\n-\t\t\t       all - reaches - 1,\n-\t\t\t       reaches - 1,\n-\t\t\t       all,\n-\t\t\t       estimate_bisect_steps(all));\n-\t\t\treturn 0;\n-\t\t}\n+\t\tif (bisect_show_vars)\n+\t\t\treturn show_bisect_vars(reaches, all, bisect_find_all);\n \t}\n \n \ttraverse_commit_list(&revs,\n-- \n1.6.2.1.317.g3d804\n"}]}