| 398 | } |
| 399 | |
| 400 | void find_bisection(struct commit_list **commit_list, int *reaches, |
| 401 | int *all, unsigned bisect_flags) |
| 402 | { |
| 403 | int nr, on_list; |
| 404 | struct commit_list *list, *p, *best, *next, *last; |
| 405 | int *weights; |
| 406 | |
| 407 | show_list("bisection 2 entry", 0, 0, *commit_list); |
| 408 | init_commit_weight(&commit_weight); |
| 409 | |
| 410 | /* |
| 411 | * Count the number of total and tree-changing items on the |
| 412 | * list, while reversing the list. |
| 413 | */ |
| 414 | for (nr = on_list = 0, last = NULL, p = *commit_list; |
| 415 | p; |
| 416 | p = next) { |
| 417 | unsigned commit_flags = p->item->object.flags; |
| 418 | |
| 419 | next = p->next; |
| 420 | if (commit_flags & UNINTERESTING) { |
| 421 | free(p); |
| 422 | continue; |
| 423 | } |
| 424 | p->next = last; |
| 425 | last = p; |
| 426 | if (!(commit_flags & TREESAME)) |
| 427 | nr++; |
| 428 | on_list++; |
| 429 | } |
| 430 | list = last; |
| 431 | show_list("bisection 2 sorted", 0, nr, list); |
| 432 | |
| 433 | *all = nr; |
| 434 | CALLOC_ARRAY(weights, on_list); |
| 435 | |
| 436 | /* Do the real work of finding bisection commit. */ |
| 437 | best = do_find_bisection(list, nr, weights, bisect_flags); |
| 438 | if (best) { |
| 439 | if (!(bisect_flags & FIND_BISECTION_ALL)) { |
| 440 | list->item = best->item; |
| 441 | commit_list_free(list->next); |
| 442 | best = list; |
| 443 | best->next = NULL; |
| 444 | } |
| 445 | *reaches = weight(best); |
| 446 | } |
| 447 | *commit_list = best; |
| 448 | |
| 449 | free(weights); |
| 450 | clear_commit_weight(&commit_weight); |
| 451 | } |
| 452 | |
| 453 | static int register_ref(const struct reference *ref, void *cb_data UNUSED) |
| 454 | { |
no test coverage detected