| 487 | } |
| 488 | |
| 489 | static int merge_changes(struct notes_merge_options *o, |
| 490 | struct notes_merge_pair *changes, int *num_changes, |
| 491 | struct notes_tree *t) |
| 492 | { |
| 493 | int i, conflicts = 0; |
| 494 | |
| 495 | trace_printf("\tmerge_changes(num_changes = %i)\n", *num_changes); |
| 496 | for (i = 0; i < *num_changes; i++) { |
| 497 | struct notes_merge_pair *p = changes + i; |
| 498 | trace_printf("\t\t%.7s: %.7s -> %.7s/%.7s\n", |
| 499 | oid_to_hex(&p->obj), oid_to_hex(&p->base), |
| 500 | oid_to_hex(&p->local), |
| 501 | oid_to_hex(&p->remote)); |
| 502 | |
| 503 | if (oideq(&p->base, &p->remote)) { |
| 504 | /* no remote change; nothing to do */ |
| 505 | trace_printf("\t\t\tskipping (no remote change)\n"); |
| 506 | } else if (oideq(&p->local, &p->remote)) { |
| 507 | /* same change in local and remote; nothing to do */ |
| 508 | trace_printf("\t\t\tskipping (local == remote)\n"); |
| 509 | } else if (oideq(&p->local, &uninitialized) || |
| 510 | oideq(&p->local, &p->base)) { |
| 511 | /* no local change; adopt remote change */ |
| 512 | trace_printf("\t\t\tno local change, adopted remote\n"); |
| 513 | if (add_note(t, &p->obj, &p->remote, |
| 514 | combine_notes_overwrite)) |
| 515 | BUG("combine_notes_overwrite failed"); |
| 516 | } else { |
| 517 | /* need file-level merge between local and remote */ |
| 518 | trace_printf("\t\t\tneed content-level merge\n"); |
| 519 | conflicts += merge_one_change(o, p, t); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | return conflicts; |
| 524 | } |
| 525 | |
| 526 | static int merge_from_diffs(struct notes_merge_options *o, |
| 527 | const struct object_id *base, |
no test coverage detected