Merge branch 'js/rebase-merge-octopus'
authorJunio C Hamano <gitster@pobox.com>
Thu, 2 Aug 2018 22:30:44 +0000 (15:30 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 2 Aug 2018 22:30:44 +0000 (15:30 -0700)
"git rebase --rebase-merges" mode now handles octopus merges as
well.

* js/rebase-merge-octopus:
rebase --rebase-merges: adjust man page for octopus support
rebase --rebase-merges: add support for octopus merges
merge: allow reading the merge commit message from a file

1  2 
Documentation/git-rebase.txt
builtin/merge.c
sequencer.c
Simple merge
diff --cc builtin/merge.c
Simple merge
diff --cc sequencer.c
index 5a068fd35116a1e664d7cefbd363e984be6cc0b6,bcc43699cd92fa517b06746a833e1181ff5e275d..f12b61fc935c9f85f47738fa922bad26a89d4043
@@@ -2987,9 -3018,52 +3027,52 @@@ static int do_merge(struct commit *comm
                goto leave_merge;
        }
  
 -              argv_array_push(&cmd.args, git_path_merge_msg());
+       if (to_merge->next) {
+               /* Octopus merge */
+               struct child_process cmd = CHILD_PROCESS_INIT;
+               if (read_env_script(&cmd.env_array)) {
+                       const char *gpg_opt = gpg_sign_opt_quoted(opts);
+                       ret = error(_(staged_changes_advice), gpg_opt, gpg_opt);
+                       goto leave_merge;
+               }
+               cmd.git_cmd = 1;
+               argv_array_push(&cmd.args, "merge");
+               argv_array_push(&cmd.args, "-s");
+               argv_array_push(&cmd.args, "octopus");
+               argv_array_push(&cmd.args, "--no-edit");
+               argv_array_push(&cmd.args, "--no-ff");
+               argv_array_push(&cmd.args, "--no-log");
+               argv_array_push(&cmd.args, "--no-stat");
+               argv_array_push(&cmd.args, "-F");
 -              unlink(git_path_cherry_pick_head());
++              argv_array_push(&cmd.args, git_path_merge_msg(the_repository));
+               if (opts->gpg_sign)
+                       argv_array_push(&cmd.args, opts->gpg_sign);
+               /* Add the tips to be merged */
+               for (j = to_merge; j; j = j->next)
+                       argv_array_push(&cmd.args,
+                                       oid_to_hex(&j->item->object.oid));
+               strbuf_release(&ref_name);
++              unlink(git_path_cherry_pick_head(the_repository));
+               rollback_lock_file(&lock);
+               rollback_lock_file(&lock);
+               ret = run_command(&cmd);
+               /* force re-reading of the cache */
+               if (!ret && (discard_cache() < 0 || read_cache() < 0))
+                       ret = error(_("could not read index"));
+               goto leave_merge;
+       }
+       merge_commit = to_merge->item;
        write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ,
 -                    git_path_merge_head(), 0);
 -      write_message("no-ff", 5, git_path_merge_mode(), 0);
 +                    git_path_merge_head(the_repository), 0);
 +      write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
  
        bases = get_merge_bases(head_commit, merge_commit);
        if (bases && !oidcmp(&merge_commit->object.oid,