Merge branch 'jc/merge-reduce-parents-early'
authorJunio C Hamano <gitster@pobox.com>
Fri, 27 Apr 2012 20:59:20 +0000 (13:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Apr 2012 20:59:20 +0000 (13:59 -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/fmt-merge-msg.c
builtin/merge.c
t/t7602-merge-octopus-many.sh

Simple merge
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);
index bce0bd37cb6006f29b9c8c532863947c44509486,7117b57ccc9e20a2a6f4d10705b8a5665db8b30e..3b72c097ee0c9538d4e8003639ab7c44126c49d6
@@@ -78,9 -76,9 +76,9 @@@ Merge made by the 'recursive' strategy
   create mode 100644 c5.c
  EOF
  
- test_expect_success 'merge up-to-date output uses pretty names' '
-       git merge c4 c5 >actual &&
+ test_expect_success 'merge reduces irrelevant remote heads' '
+       GIT_MERGE_VERBOSITY=0 git merge c4 c5 >actual &&
 -      test_cmp expected actual
 +      test_i18ncmp expected actual
  '
  
  cat >expected <<\EOF