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

Function cmd_merge

builtin/merge.c:1363–1887  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363int cmd_merge(int argc,
1364 const char **argv,
1365 const char *prefix,
1366 struct repository *repo UNUSED)
1367{
1368 struct object_id result_tree, stash, head_oid;
1369 struct commit *head_commit;
1370 struct strbuf buf = STRBUF_INIT;
1371 int i, ret = 0, head_subsumed;
1372 int best_cnt = -1, merge_was_ok = 0, automerge_was_ok = 0;
1373 struct commit_list *common = NULL;
1374 const char *best_strategy = NULL, *wt_strategy = NULL;
1375 struct commit_list *remoteheads = NULL, *p;
1376 void *branch_to_free;
1377 int orig_argc = argc;
1378 int merge_log_config = -1;
1379
1380 show_usage_with_options_if_asked(argc, argv,
1381 builtin_merge_usage, builtin_merge_options);
1382
1383#ifndef WITH_BREAKING_CHANGES
1384 warn_on_auto_comment_char = true;
1385#endif /* !WITH_BREAKING_CHANGES */
1386 prepare_repo_settings(the_repository);
1387 the_repository->settings.command_requires_full_index = 0;
1388
1389 /*
1390 * Check if we are _not_ on a detached HEAD, i.e. if there is a
1391 * current branch.
1392 */
1393 branch = branch_to_free = refs_resolve_refdup(get_main_ref_store(the_repository),
1394 "HEAD", 0, &head_oid,
1395 NULL);
1396 if (branch)
1397 skip_prefix(branch, "refs/heads/", &branch);
1398
1399 init_diff_ui_defaults();
1400 repo_config(the_repository, git_merge_config, &merge_log_config);
1401
1402 if (!branch || is_null_oid(&head_oid))
1403 head_commit = NULL;
1404 else
1405 head_commit = lookup_commit_or_die(&head_oid, "HEAD");
1406
1407 if (branch_mergeoptions)
1408 parse_branch_merge_options(branch_mergeoptions);
1409 argc = parse_options(argc, argv, prefix, builtin_merge_options,
1410 builtin_merge_usage, 0);
1411 if (shortlog_len < 0)
1412 shortlog_len = (merge_log_config > 0) ? merge_log_config : 0;
1413
1414 if (verbosity < 0 && show_progress == -1)
1415 show_progress = 0;
1416
1417 if (abort_current_merge) {
1418 int nargc = 2;
1419 const char *nargv[] = {"reset", "--merge", NULL};
1420 char stash_oid_hex[GIT_MAX_HEXSZ + 1];

Callers

nothing calls this directly

Calls 15

prepare_repo_settingsFunction · 0.85
refs_resolve_refdupFunction · 0.85
get_main_ref_storeFunction · 0.85
init_diff_ui_defaultsFunction · 0.85
is_null_oidFunction · 0.85
lookup_commit_or_dieFunction · 0.85
parse_optionsFunction · 0.85
usage_msg_optFunction · 0.85
file_existsFunction · 0.85
refs_read_refFunction · 0.85

Tested by

no test coverage detected