{"thread":{"id":"9864","subject":"[PATCH 2/3] rev-list --bisect: Move some bisection code into best_bisection.","startedAt":"2007-09-15T11:00:05Z","lastAt":"2007-09-15T11:00:05Z","messageCount":1,"participants":["Christian Couder"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"53105","messageId":"20070915130005.6141f3d2.chriscool@tuxfamily.org","threadId":"9864","inReplyTo":null,"subject":"[PATCH 2/3] rev-list --bisect: Move some bisection code into best_bisection.","fromName":"Christian Couder","fromEmail":"chriscool@tuxfamily.org","sentAt":"2007-09-15T11:00:05Z","receivedAt":"2007-09-15T11:00:05Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"Signed-off-by: Christian Couder <chriscool@tuxfamily.org>\n---\n builtin-rev-list.c |   19 +++++++++++++++----\n 1 files changed, 15 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin-rev-list.c b/builtin-rev-list.c\nindex f32c712..c2ce1fc 100644\n--- a/builtin-rev-list.c\n+++ b/builtin-rev-list.c\n@@ -258,6 +258,8 @@ static void show_list(const char *debug, int counted, int nr,\n static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\t\t     int nr, int *weights);\n \n+static struct commit_list *best_bisection(struct commit_list *list, int nr);\n+\n /*\n  * zero or positive weight is the number of interesting commits it can\n  * reach, including itself.  Especially, weight = 0 means it does not\n@@ -321,7 +323,7 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\t\t\t\t     int nr, int *weights)\n {\n \tint n, counted, distance;\n-\tstruct commit_list *p, *best;\n+\tstruct commit_list *p;\n \n \tcounted = 0;\n \n@@ -426,9 +428,17 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \tshow_list(\"bisection 2 counted all\", counted, nr, list);\n \n \t/* Then find the best one */\n-\tcounted = -1;\n+\treturn best_bisection(list, nr);\n+}\n+\n+static struct commit_list *best_bisection(struct commit_list *list, int nr)\n+{\n+\tstruct commit_list *p, *best;\n+\tint best_distance = -1;\n+\n \tbest = list;\n \tfor (p = list; p; p = p->next) {\n+\t\tint distance;\n \t\tunsigned flags = p->item->object.flags;\n \n \t\tif (revs.prune_fn && !(flags & TREECHANGE))\n@@ -436,11 +446,12 @@ static struct commit_list *do_find_bisection(struct commit_list *list,\n \t\tdistance = weight(p);\n \t\tif (nr - distance < distance)\n \t\t\tdistance = nr - distance;\n-\t\tif (distance > counted) {\n+\t\tif (distance > best_distance) {\n \t\t\tbest = p;\n-\t\t\tcounted = distance;\n+\t\t\tbest_distance = distance;\n \t\t}\n \t}\n+\n \treturn best;\n }\n \n-- \n1.5.3.1.20.g2a16-dirty\n"}]}