| 36 | } |
| 37 | |
| 38 | static struct combine_diff_path *intersect_paths( |
| 39 | struct combine_diff_path *curr, |
| 40 | int n, |
| 41 | int num_parent, |
| 42 | int combined_all_paths) |
| 43 | { |
| 44 | struct diff_queue_struct *q = &diff_queued_diff; |
| 45 | struct combine_diff_path *p, **tail = &curr; |
| 46 | int i, j, cmp; |
| 47 | |
| 48 | if (!n) { |
| 49 | for (i = 0; i < q->nr; i++) { |
| 50 | if (diff_unmodified_pair(q->queue[i])) |
| 51 | continue; |
| 52 | p = combine_diff_path_new(q->queue[i]->two->path, |
| 53 | strlen(q->queue[i]->two->path), |
| 54 | q->queue[i]->two->mode, |
| 55 | &q->queue[i]->two->oid, |
| 56 | num_parent); |
| 57 | oidcpy(&p->parent[n].oid, &q->queue[i]->one->oid); |
| 58 | p->parent[n].mode = q->queue[i]->one->mode; |
| 59 | p->parent[n].status = q->queue[i]->status; |
| 60 | |
| 61 | if (combined_all_paths && |
| 62 | filename_changed(p->parent[n].status)) { |
| 63 | p->parent[n].path = xstrdup(q->queue[i]->one->path); |
| 64 | } |
| 65 | *tail = p; |
| 66 | tail = &p->next; |
| 67 | } |
| 68 | return curr; |
| 69 | } |
| 70 | |
| 71 | /* |
| 72 | * paths in curr (linked list) and q->queue[] (array) are |
| 73 | * both sorted in the tree order. |
| 74 | */ |
| 75 | i = 0; |
| 76 | while ((p = *tail) != NULL) { |
| 77 | cmp = ((i >= q->nr) |
| 78 | ? -1 : compare_paths(p, q->queue[i]->two)); |
| 79 | |
| 80 | if (cmp < 0) { |
| 81 | /* p->path not in q->queue[]; drop it */ |
| 82 | *tail = p->next; |
| 83 | for (j = 0; j < num_parent; j++) |
| 84 | free(p->parent[j].path); |
| 85 | free(p); |
| 86 | continue; |
| 87 | } |
| 88 | |
| 89 | if (cmp > 0) { |
| 90 | /* q->queue[i] not in p->path; skip it */ |
| 91 | i++; |
| 92 | continue; |
| 93 | } |
| 94 | |
| 95 | oidcpy(&p->parent[n].oid, &q->queue[i]->one->oid); |
no test coverage detected