MCPcopy Index your code
hub / github.com/git/git / merge_commit

Function merge_commit

builtin/notes.c:817–871  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

815}
816
817static int merge_commit(struct notes_merge_options *o)
818{
819 struct strbuf msg = STRBUF_INIT;
820 struct object_id oid, parent_oid;
821 struct notes_tree t = {0};
822 struct commit *partial;
823 struct pretty_print_context pretty_ctx;
824 void *local_ref_to_free;
825 int ret;
826
827 /*
828 * Read partial merge result from .git/NOTES_MERGE_PARTIAL,
829 * and target notes ref from .git/NOTES_MERGE_REF.
830 */
831
832 if (repo_get_oid(the_repository, "NOTES_MERGE_PARTIAL", &oid))
833 die(_("failed to read ref NOTES_MERGE_PARTIAL"));
834 else if (!(partial = lookup_commit_reference(the_repository, &oid)))
835 die(_("could not find commit from NOTES_MERGE_PARTIAL."));
836 else if (repo_parse_commit(the_repository, partial))
837 die(_("could not parse commit from NOTES_MERGE_PARTIAL."));
838
839 if (partial->parents)
840 oidcpy(&parent_oid, &partial->parents->item->object.oid);
841 else
842 oidclr(&parent_oid, the_repository->hash_algo);
843
844 init_notes(&t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
845
846 o->local_ref = local_ref_to_free =
847 refs_resolve_refdup(get_main_ref_store(the_repository),
848 "NOTES_MERGE_REF", 0, &oid, NULL);
849 if (!o->local_ref)
850 die(_("failed to resolve NOTES_MERGE_REF"));
851
852 if (notes_merge_commit(o, &t, partial, &oid))
853 die(_("failed to finalize notes merge"));
854
855 /* Reuse existing commit message in reflog message */
856 memset(&pretty_ctx, 0, sizeof(pretty_ctx));
857 repo_format_commit_message(the_repository, partial, "%s", &msg,
858 &pretty_ctx);
859 strbuf_trim(&msg);
860 strbuf_insertstr(&msg, 0, "notes: ");
861 refs_update_ref(get_main_ref_store(the_repository), msg.buf,
862 o->local_ref, &oid,
863 is_null_oid(&parent_oid) ? NULL : &parent_oid,
864 0, UPDATE_REFS_DIE_ON_ERR);
865
866 free_notes(&t);
867 strbuf_release(&msg);
868 ret = merge_abort(o);
869 free(local_ref_to_free);
870 return ret;
871}
872
873static int git_config_get_notes_strategy(const char *key,
874 enum notes_merge_strategy *strategy)

Callers 1

mergeFunction · 0.85

Calls 15

repo_get_oidFunction · 0.85
lookup_commit_referenceFunction · 0.85
repo_parse_commitFunction · 0.85
oidcpyFunction · 0.85
oidclrFunction · 0.85
init_notesFunction · 0.85
refs_resolve_refdupFunction · 0.85
get_main_ref_storeFunction · 0.85
notes_merge_commitFunction · 0.85
strbuf_trimFunction · 0.85
strbuf_insertstrFunction · 0.85

Tested by

no test coverage detected