MCPcopy Create free account
hub / github.com/git/git / notes_merge

Function notes_merge

notes-merge.c:554–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

552}
553
554int notes_merge(struct notes_merge_options *o,
555 struct notes_tree *local_tree,
556 struct object_id *result_oid)
557{
558 struct object_id local_oid, remote_oid;
559 struct commit *local, *remote;
560 struct commit_list *bases = NULL;
561 const struct object_id *base_oid, *base_tree_oid;
562 int result = 0;
563
564 assert(o->local_ref && o->remote_ref);
565 assert(!strcmp(o->local_ref, local_tree->ref));
566 oidclr(result_oid, the_repository->hash_algo);
567
568 trace_printf("notes_merge(o->local_ref = %s, o->remote_ref = %s)\n",
569 o->local_ref, o->remote_ref);
570
571 /* Dereference o->local_ref into local_sha1 */
572 if (refs_read_ref_full(get_main_ref_store(the_repository), o->local_ref, 0, &local_oid, NULL))
573 die("Failed to resolve local notes ref '%s'", o->local_ref);
574 else if (!check_refname_format(o->local_ref, 0) &&
575 is_null_oid(&local_oid))
576 local = NULL; /* local_oid == null_oid indicates unborn ref */
577 else if (!(local = lookup_commit_reference(o->repo, &local_oid)))
578 die("Could not parse local commit %s (%s)",
579 oid_to_hex(&local_oid), o->local_ref);
580 trace_printf("\tlocal commit: %.7s\n", oid_to_hex(&local_oid));
581
582 /* Dereference o->remote_ref into remote_oid */
583 if (repo_get_oid(the_repository, o->remote_ref, &remote_oid)) {
584 /*
585 * Failed to get remote_oid. If o->remote_ref looks like an
586 * unborn ref, perform the merge using an empty notes tree.
587 */
588 if (!check_refname_format(o->remote_ref, 0)) {
589 oidclr(&remote_oid, the_repository->hash_algo);
590 remote = NULL;
591 } else {
592 die("Failed to resolve remote notes ref '%s'",
593 o->remote_ref);
594 }
595 } else if (!(remote = lookup_commit_reference(o->repo, &remote_oid))) {
596 die("Could not parse remote commit %s (%s)",
597 oid_to_hex(&remote_oid), o->remote_ref);
598 }
599 trace_printf("\tremote commit: %.7s\n", oid_to_hex(&remote_oid));
600
601 if (!local && !remote)
602 die("Cannot merge empty notes ref (%s) into empty notes ref "
603 "(%s)", o->remote_ref, o->local_ref);
604 if (!local) {
605 /* result == remote commit */
606 oidcpy(result_oid, &remote_oid);
607 goto found_result;
608 }
609 if (!remote) {
610 /* result == local commit */
611 oidcpy(result_oid, &local_oid);

Callers 1

mergeFunction · 0.85

Calls 15

oidclrFunction · 0.85
refs_read_ref_fullFunction · 0.85
get_main_ref_storeFunction · 0.85
check_refname_formatFunction · 0.85
is_null_oidFunction · 0.85
lookup_commit_referenceFunction · 0.85
oid_to_hexFunction · 0.85
repo_get_oidFunction · 0.85
oidcpyFunction · 0.85
repo_get_merge_basesFunction · 0.85
null_oidFunction · 0.85
get_commit_tree_oidFunction · 0.85

Tested by

no test coverage detected