{"thread":{"id":"18279","subject":"[PATCH 5/7] rev-list: move code to show bisect vars into its own function","startedAt":"2009-03-12T07:51:31Z","lastAt":"2009-03-12T07:51:31Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"107776","messageId":"20090312085131.9c923d14.chriscool@tuxfamily.org","threadId":"18279","inReplyTo":null,"subject":"[PATCH 5/7] rev-list: move code to show bisect vars into its own function","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2009-03-12T07:51:31Z","receivedAt":"2009-03-12T07:51:31Z","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 |  101 ++++++++++++++++++++++++++++------------------------\n 1 files changed, 54 insertions(+), 47 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex b50d304..6e0466e 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -237,6 +237,57 @@ static void show_tried(struct commit_list *tried)\n \tprintf(\"'\\n\");\n }\n \n+static int show_bisect_vars(int reaches, int all, int show_all, int skip)\n+{\n+\tint cnt;\n+\tchar hex[41];\n+\tstruct commit_list *tried;\n+\n+\trevs.commits = filter_skipped(revs.commits, &tried, show_all);\n+\n+\tif (!revs.commits && !skip)\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+\tif (revs.commits)\n+\t\tstrcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));\n+\telse\n+\t\thex[0] = '\\0';\n+\n+\tif (show_all) {\n+\t\ttraverse_commit_list(&revs, show_commit, show_object);\n+\t\tprintf(\"------\\n\");\n+\t}\n+\n+\tif (skip)\n+\t\tshow_tried(tried);\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@@ -332,57 +383,13 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)\n \n \tif (bisect_list) {\n \t\tint reaches = reaches, all = all;\n-\t\tstruct commit_list *tried;\n \n \t\trevs.commits = find_bisection(revs.commits, &reaches, &all,\n \t\t\t\t\t      bisect_find_all);\n \n-\t\trevs.commits = filter_skipped(revs.commits, &tried,\n-\t\t\t\t\t      bisect_show_all);\n-\n-\t\tif (bisect_show_vars) {\n-\t\t\tint cnt;\n-\t\t\tchar hex[41];\n-\t\t\tif (!revs.commits && !bisect_skip)\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\tif (revs.commits)\n-\t\t\t\tstrcpy(hex, sha1_to_hex(revs.commits->item->object.sha1));\n-\t\t\telse\n-\t\t\t\thex[0] = '\\0';\n-\n-\t\t\tif (bisect_show_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\tif (bisect_skip)\n-\t\t\t\tshow_tried(tried);\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,\n+\t\t\t\t\t\tbisect_show_all, bisect_skip);\n \t}\n \n \ttraverse_commit_list(&revs,\n-- \n1.6.2.83.g012a16.dirty\n"}]}