| 129 | }; |
| 130 | |
| 131 | static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o, |
| 132 | const struct object_id *base, |
| 133 | const struct object_id *remote, |
| 134 | int *num_changes) |
| 135 | { |
| 136 | struct diff_options opt; |
| 137 | struct notes_merge_pair *changes; |
| 138 | int i, len = 0; |
| 139 | |
| 140 | trace_printf("\tdiff_tree_remote(base = %.7s, remote = %.7s)\n", |
| 141 | oid_to_hex(base), oid_to_hex(remote)); |
| 142 | |
| 143 | repo_diff_setup(o->repo, &opt); |
| 144 | opt.flags.recursive = 1; |
| 145 | opt.output_format = DIFF_FORMAT_NO_OUTPUT; |
| 146 | diff_setup_done(&opt); |
| 147 | diff_tree_oid(base, remote, "", &opt); |
| 148 | diffcore_std(&opt); |
| 149 | |
| 150 | CALLOC_ARRAY(changes, diff_queued_diff.nr); |
| 151 | |
| 152 | for (i = 0; i < diff_queued_diff.nr; i++) { |
| 153 | struct diff_filepair *p = diff_queued_diff.queue[i]; |
| 154 | struct notes_merge_pair *mp; |
| 155 | int occupied; |
| 156 | struct object_id obj; |
| 157 | |
| 158 | if (verify_notes_filepair(p, &obj)) { |
| 159 | trace_printf("\t\tCannot merge entry '%s' (%c): " |
| 160 | "%.7s -> %.7s. Skipping!\n", p->one->path, |
| 161 | p->status, oid_to_hex(&p->one->oid), |
| 162 | oid_to_hex(&p->two->oid)); |
| 163 | continue; |
| 164 | } |
| 165 | mp = find_notes_merge_pair_pos(changes, len, &obj, 1, &occupied); |
| 166 | if (occupied) { |
| 167 | /* We've found an addition/deletion pair */ |
| 168 | assert(oideq(&mp->obj, &obj)); |
| 169 | if (is_null_oid(&p->one->oid)) { /* addition */ |
| 170 | assert(is_null_oid(&mp->remote)); |
| 171 | oidcpy(&mp->remote, &p->two->oid); |
| 172 | } else if (is_null_oid(&p->two->oid)) { /* deletion */ |
| 173 | assert(is_null_oid(&mp->base)); |
| 174 | oidcpy(&mp->base, &p->one->oid); |
| 175 | } else |
| 176 | assert(!"Invalid existing change recorded"); |
| 177 | } else { |
| 178 | oidcpy(&mp->obj, &obj); |
| 179 | oidcpy(&mp->base, &p->one->oid); |
| 180 | oidcpy(&mp->local, &uninitialized); |
| 181 | oidcpy(&mp->remote, &p->two->oid); |
| 182 | len++; |
| 183 | } |
| 184 | trace_printf("\t\tStored remote change for %s: %.7s -> %.7s\n", |
| 185 | oid_to_hex(&mp->obj), oid_to_hex(&mp->base), |
| 186 | oid_to_hex(&mp->remote)); |
| 187 | } |
| 188 | diff_flush(&opt); |
no test coverage detected