Merge branch 'jc/want-commit'
authorJunio C Hamano <gitster@pobox.com>
Wed, 5 Oct 2011 19:35:55 +0000 (12:35 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 5 Oct 2011 19:35:55 +0000 (12:35 -0700)
* jc/want-commit:
Allow git merge ":/<pattern>"

1  2 
builtin/merge.c
diff --combined builtin/merge.c
index ab4077f272919fb47e3c5f179dc42fc9baad68bb,e2e981feda6f241623c4799881b27e4e21987525..ee56974371fa9224ecb4b8203fb1356b6cf6e156
@@@ -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);
        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)
  {
        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,
                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);
                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);
                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;