* zero or positive weight is the number of interesting commits it can * reach, including itself. Especially, weight = 0 means it does not * reach any tree-changing commits (e.g. just above uninteresting one * but traversal is with pathspec). * * weight = -1 means it has one parent and its distance is yet to * be computed. * * weight = -2 means it has more than one parent and its distance
| 279 | * or positive distance. |
| 280 | */ |
| 281 | static struct commit_list *do_find_bisection(struct commit_list *list, |
| 282 | int nr, int *weights, |
| 283 | unsigned bisect_flags) |
| 284 | { |
| 285 | int n, counted; |
| 286 | struct commit_list *p; |
| 287 | |
| 288 | counted = 0; |
| 289 | |
| 290 | for (n = 0, p = list; p; p = p->next) { |
| 291 | struct commit *commit = p->item; |
| 292 | unsigned commit_flags = commit->object.flags; |
| 293 | |
| 294 | *commit_weight_at(&commit_weight, p->item) = &weights[n++]; |
| 295 | switch (count_interesting_parents(commit, bisect_flags)) { |
| 296 | case 0: |
| 297 | if (!(commit_flags & TREESAME)) { |
| 298 | weight_set(p, 1); |
| 299 | counted++; |
| 300 | show_list("bisection 2 count one", |
| 301 | counted, nr, list); |
| 302 | } |
| 303 | /* |
| 304 | * otherwise, it is known not to reach any |
| 305 | * tree-changing commit and gets weight 0. |
| 306 | */ |
| 307 | break; |
| 308 | case 1: |
| 309 | weight_set(p, -1); |
| 310 | break; |
| 311 | default: |
| 312 | weight_set(p, -2); |
| 313 | break; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | show_list("bisection 2 initialize", counted, nr, list); |
| 318 | |
| 319 | /* |
| 320 | * If you have only one parent in the resulting set |
| 321 | * then you can reach one commit more than that parent |
| 322 | * can reach. So we do not have to run the expensive |
| 323 | * count_distance() for single strand of pearls. |
| 324 | * |
| 325 | * However, if you have more than one parents, you cannot |
| 326 | * just add their distance and one for yourself, since |
| 327 | * they usually reach the same ancestor and you would |
| 328 | * end up counting them twice that way. |
| 329 | * |
| 330 | * So we will first count distance of merges the usual |
| 331 | * way, and then fill the blanks using cheaper algorithm. |
| 332 | */ |
| 333 | for (p = list; p; p = p->next) { |
| 334 | if (p->item->object.flags & UNINTERESTING) |
| 335 | continue; |
| 336 | if (weight(p) != -2) |
| 337 | continue; |
| 338 | if (bisect_flags & FIND_BISECTION_FIRST_PARENT_ONLY) |
no test coverage detected