Merge branch 'jc/merge-reduce-parents-early' into maint
authorJunio C Hamano <gitster@pobox.com>
Thu, 3 May 2012 22:36:15 +0000 (15:36 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 3 May 2012 22:36:15 +0000 (15:36 -0700)
Octopus merge strategy did not reduce heads that are recorded in the final
commit correctly.

By Junio C Hamano (4) and Michał Kiedrowicz (1)
* jc/merge-reduce-parents-early:
  fmt-merge-msg: discard needless merge parents
  builtin/merge.c: reduce parents early
  builtin/merge.c: collect other parents early
  builtin/merge.c: remove "remoteheads" global variable
  merge tests: octopus with redundant parents

1  2 
builtin/merge.c

diff --cc builtin/merge.c
index 08e01e8a60d7d7f9c60e9e7a3a2f8b4d66c12ce3,20aeca0b3c29f3c1c0e037b25f630eb0d9bbf34e..470fc57c5d6ceabedbd866a5db35d3123a764af0
@@@ -905,14 -904,14 +906,14 @@@ static void prepare_to_commit(struct co
        write_merge_msg(&msg);
        run_hook(get_index_file(), "prepare-commit-msg",
                 git_path("MERGE_MSG"), "merge", NULL, NULL);
 -      if (option_edit) {
 +      if (0 < option_edit) {
                if (launch_editor(git_path("MERGE_MSG"), NULL, NULL))
-                       abort_commit(NULL);
+                       abort_commit(remoteheads, NULL);
        }
        read_merge_msg(&msg);
 -      stripspace(&msg, option_edit);
 +      stripspace(&msg, 0 < option_edit);
        if (!msg.len)
-               abort_commit(_("Empty commit message."));
+               abort_commit(remoteheads, _("Empty commit message."));
        strbuf_release(&merge_msg);
        strbuf_addbuf(&merge_msg, &msg);
        strbuf_release(&msg);
@@@ -1330,10 -1356,13 +1356,12 @@@ int cmd_merge(int argc, const char **ar
        }
  
        if (option_edit < 0)
 -              option_edit = 0;
 +              option_edit = default_edit_option();
  
        if (!use_strategies) {
-               if (!remoteheads->next)
+               if (!remoteheads)
+                       ; /* already up-to-date */
+               else if (!remoteheads->next)
                        add_strategies(pull_twohead, DEFAULT_TWOHEAD);
                else
                        add_strategies(pull_octopus, DEFAULT_OCTOPUS);