From: Junio C Hamano Date: Wed, 5 Oct 2011 19:35:55 +0000 (-0700) Subject: Merge branch 'jc/want-commit' X-Git-Tag: v1.7.8-rc0~149 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c672f01c0410eef621b0df3574bfcfe433139f04?hp=-c Merge branch 'jc/want-commit' * jc/want-commit: Allow git merge ":/" --- c672f01c0410eef621b0df3574bfcfe433139f04 diff --combined builtin/merge.c index ab4077f272,e2e981feda..ee56974371 --- a/builtin/merge.c +++ b/builtin/merge.c @@@ -390,6 -390,8 +390,6 @@@ static void finish(const unsigned char opts.output_format |= DIFF_FORMAT_SUMMARY | DIFF_FORMAT_DIFFSTAT; opts.detect_rename = DIFF_DETECT_RENAME; - if (diff_use_color_default > 0) - DIFF_OPT_SET(&opts, COLOR_DIFF); if (diff_setup_done(&opts) < 0) die(_("diff_setup_done failed")); diff_tree_sha1(head, new_head, "", &opts); @@@ -403,6 -405,16 +403,16 @@@ strbuf_release(&reflog_message); } + static struct object *want_commit(const char *name) + { + struct object *obj; + unsigned char sha1[20]; + if (get_sha1(name, sha1)) + return NULL; + obj = parse_object(sha1); + return peel_to_type(name, 0, obj, OBJ_COMMIT); + } + /* Get the name for the merge commit's message. */ static void merge_name(const char *remote, struct strbuf *msg) { @@@ -418,7 -430,7 +428,7 @@@ remote = bname.buf; memset(branch_head, 0, sizeof(branch_head)); - remote_head = peel_to_type(remote, 0, NULL, OBJ_COMMIT); + remote_head = want_commit(remote); if (!remote_head) die(_("'%s' does not point to a commit"), remote); @@@ -901,7 -913,7 +911,7 @@@ static int finish_automerge(struct comm strbuf_addch(&merge_msg, '\n'); run_prepare_commit_msg(); commit_tree(merge_msg.buf, result_tree, parents, result_commit, NULL); - strbuf_addf(&buf, "Merge made by %s.", wt_strategy); + strbuf_addf(&buf, "Merge made by the '%s' strategy.", wt_strategy); finish(result_commit, buf.buf); strbuf_release(&buf); drop_save(); @@@ -1031,6 -1043,10 +1041,6 @@@ int cmd_merge(int argc, const char **ar git_config(git_merge_config, NULL); - /* for color.ui */ - if (diff_use_color_default == -1) - diff_use_color_default = git_use_color_default; - if (branch_mergeoptions) parse_branch_merge_options(branch_mergeoptions); argc = parse_options(argc, argv, prefix, builtin_merge_options, @@@ -1124,7 -1140,7 +1134,7 @@@ if (!allow_fast_forward) die(_("Non-fast-forward commit does not make sense into " "an empty head")); - remote_head = peel_to_type(argv[0], 0, NULL, OBJ_COMMIT); + remote_head = want_commit(argv[0]); if (!remote_head) die(_("%s - not something we can merge"), argv[0]); read_empty(remote_head->sha1, 0); @@@ -1170,7 -1186,7 +1180,7 @@@ struct object *o; struct commit *commit; - o = peel_to_type(argv[i], 0, NULL, OBJ_COMMIT); + o = want_commit(argv[i]); if (!o) die(_("%s - not something we can merge"), argv[i]); commit = lookup_commit(o->sha1); @@@ -1238,8 -1254,7 +1248,7 @@@ if (have_message) strbuf_addstr(&msg, " (no commit created; -m option ignored)"); - o = peel_to_type(sha1_to_hex(remoteheads->item->object.sha1), - 0, NULL, OBJ_COMMIT); + o = want_commit(sha1_to_hex(remoteheads->item->object.sha1)); if (!o) return 1;