* Return a single relevant commit from a parent list. If we are a TREESAME * commit, and this selects one of our parents, then we can safely simplify to * that parent. */
| 532 | * that parent. |
| 533 | */ |
| 534 | static struct commit *one_relevant_parent(const struct rev_info *revs, |
| 535 | struct commit_list *orig) |
| 536 | { |
| 537 | struct commit_list *list = orig; |
| 538 | struct commit *relevant = NULL; |
| 539 | |
| 540 | if (!orig) |
| 541 | return NULL; |
| 542 | |
| 543 | /* |
| 544 | * For 1-parent commits, or if first-parent-only, then return that |
| 545 | * first parent (even if not "relevant" by the above definition). |
| 546 | * TREESAME will have been set purely on that parent. |
| 547 | */ |
| 548 | if (revs->first_parent_only || !orig->next) |
| 549 | return orig->item; |
| 550 | |
| 551 | /* |
| 552 | * For multi-parent commits, identify a sole relevant parent, if any. |
| 553 | * If we have only one relevant parent, then TREESAME will be set purely |
| 554 | * with regard to that parent, and we can simplify accordingly. |
| 555 | * |
| 556 | * If we have more than one relevant parent, or no relevant parents |
| 557 | * (and multiple irrelevant ones), then we can't select a parent here |
| 558 | * and return NULL. |
| 559 | */ |
| 560 | while (list) { |
| 561 | struct commit *commit = list->item; |
| 562 | list = list->next; |
| 563 | if (relevant_commit(commit)) { |
| 564 | if (relevant) |
| 565 | return NULL; |
| 566 | relevant = commit; |
| 567 | } |
| 568 | } |
| 569 | return relevant; |
| 570 | } |
| 571 | |
| 572 | /* |
| 573 | * The goal is to get REV_TREE_NEW as the result only if the |
no test coverage detected