all input commits in one and twos[] must have been parsed! */
| 98 | |
| 99 | /* all input commits in one and twos[] must have been parsed! */ |
| 100 | static int paint_down_to_common(struct repository *r, |
| 101 | struct commit *one, int n, |
| 102 | struct commit **twos, |
| 103 | timestamp_t min_generation, |
| 104 | enum merge_base_flags mb_flags, |
| 105 | struct commit_list **result) |
| 106 | { |
| 107 | struct nonstale_queue queue = { |
| 108 | { compare_commits_by_gen_then_commit_date } |
| 109 | }; |
| 110 | int i; |
| 111 | timestamp_t last_gen = GENERATION_NUMBER_INFINITY; |
| 112 | struct commit_list **tail = result; |
| 113 | |
| 114 | if (!min_generation && !corrected_commit_dates_enabled(r)) |
| 115 | queue.pq.compare = compare_commits_by_commit_date; |
| 116 | |
| 117 | one->object.flags |= PARENT1; |
| 118 | if (!n) { |
| 119 | commit_list_append(one, result); |
| 120 | return 0; |
| 121 | } |
| 122 | nonstale_queue_put_dedup(&queue, one); |
| 123 | |
| 124 | for (i = 0; i < n; i++) { |
| 125 | twos[i]->object.flags |= PARENT2; |
| 126 | nonstale_queue_put_dedup(&queue, twos[i]); |
| 127 | } |
| 128 | |
| 129 | while (queue.max_nonstale) { |
| 130 | struct commit *commit = nonstale_queue_get_dedup(&queue); |
| 131 | struct commit_list *parents; |
| 132 | int flags; |
| 133 | timestamp_t generation = commit_graph_generation(commit); |
| 134 | |
| 135 | if (min_generation && generation > last_gen) |
| 136 | BUG("bad generation skip %"PRItime" > %"PRItime" at %s", |
| 137 | generation, last_gen, |
| 138 | oid_to_hex(&commit->object.oid)); |
| 139 | last_gen = generation; |
| 140 | |
| 141 | if (generation < min_generation) |
| 142 | break; |
| 143 | |
| 144 | flags = commit->object.flags & (PARENT1 | PARENT2 | STALE); |
| 145 | if (flags == (PARENT1 | PARENT2)) { |
| 146 | if (!(commit->object.flags & RESULT)) { |
| 147 | commit->object.flags |= RESULT; |
| 148 | tail = commit_list_append(commit, tail); |
| 149 | /* |
| 150 | * The queue is generation-ordered; no |
| 151 | * remaining common ancestor can be a |
| 152 | * descendant of this one. |
| 153 | */ |
| 154 | if (!(mb_flags & MERGE_BASE_FIND_ALL) && |
| 155 | generation < GENERATION_NUMBER_INFINITY) |
| 156 | break; |
| 157 | } |
no test coverage detected