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

Function merge

builtin/notes.c:887–1016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

885}
886
887static int merge(int argc, const char **argv, const char *prefix,
888 struct repository *repo UNUSED)
889{
890 struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
891 struct object_id result_oid;
892 struct notes_tree *t;
893 struct notes_merge_options o;
894 int do_merge = 0, do_commit = 0, do_abort = 0;
895 int verbosity = 0, result;
896 const char *strategy = NULL;
897 struct option options[] = {
898 OPT_GROUP(N_("General options")),
899 OPT__VERBOSITY(&verbosity),
900 OPT_GROUP(N_("Merge options")),
901 OPT_STRING('s', "strategy", &strategy, N_("strategy"),
902 N_("resolve notes conflicts using the given strategy "
903 "(manual/ours/theirs/union/cat_sort_uniq)")),
904 OPT_GROUP(N_("Committing unmerged notes")),
905 OPT_SET_INT_F(0, "commit", &do_commit,
906 N_("finalize notes merge by committing unmerged notes"),
907 1, PARSE_OPT_NONEG),
908 OPT_GROUP(N_("Aborting notes merge resolution")),
909 OPT_SET_INT_F(0, "abort", &do_abort,
910 N_("abort notes merge"),
911 1, PARSE_OPT_NONEG),
912 OPT_END()
913 };
914 char *notes_ref;
915
916 argc = parse_options(argc, argv, prefix, options,
917 git_notes_merge_usage, 0);
918
919 if (strategy || do_commit + do_abort == 0)
920 do_merge = 1;
921 if (do_merge + do_commit + do_abort != 1) {
922 error(_("cannot mix --commit, --abort or -s/--strategy"));
923 usage_with_options(git_notes_merge_usage, options);
924 }
925
926 if (do_merge && argc != 1) {
927 error(_("must specify a notes ref to merge"));
928 usage_with_options(git_notes_merge_usage, options);
929 } else if (!do_merge && argc) {
930 error(_("too many arguments"));
931 usage_with_options(git_notes_merge_usage, options);
932 }
933
934 init_notes_merge_options(the_repository, &o);
935 o.verbosity = verbosity + NOTES_MERGE_VERBOSITY_DEFAULT;
936
937 if (do_abort)
938 return merge_abort(&o);
939 if (do_commit)
940 return merge_commit(&o);
941
942 notes_ref = default_notes_ref(the_repository);
943 o.local_ref = notes_ref;
944 strbuf_addstr(&remote_ref, argv[0]);

Callers

nothing calls this directly

Calls 15

parse_optionsFunction · 0.85
errorFunction · 0.85
usage_with_optionsFunction · 0.85
init_notes_merge_optionsFunction · 0.85
merge_abortFunction · 0.85
merge_commitFunction · 0.85
default_notes_refFunction · 0.85
strbuf_addstrFunction · 0.85
expand_loose_notes_refFunction · 0.85
init_notes_checkFunction · 0.85
strbuf_addfFunction · 0.85

Tested by

no test coverage detected