Merge branch 'js/mailmap'
[gitweb.git] / builtin / merge.c
index e1bc5a484b41be55593176e4fd936b5647865a4d..c3c976d471ce78268e673a5135a4c37ebc6d0f6d 100644 (file)
@@ -36,6 +36,7 @@
 #include "packfile.h"
 #include "tag.h"
 #include "alias.h"
+#include "commit-reach.h"
 
 #define DEFAULT_TWOHEAD (1<<0)
 #define DEFAULT_OCTOPUS (1<<1)
@@ -223,6 +224,7 @@ static int option_parse_x(const struct option *opt,
 static int option_parse_n(const struct option *opt,
                          const char *arg, int unset)
 {
+       BUG_ON_OPT_ARG(arg);
        show_diffstat = unset;
        return 0;
 }
@@ -389,7 +391,7 @@ static void squash_message(struct commit *commit, struct commit_list *remotehead
 
        printf(_("Squash commit -- not updating HEAD\n"));
 
-       init_revisions(&rev, NULL);
+       repo_init_revisions(the_repository, &rev, NULL);
        rev.ignore_merges = 1;
        rev.commit_format = CMIT_FMT_MEDIUM;
 
@@ -452,7 +454,7 @@ static void finish(struct commit *head_commit,
        }
        if (new_head && show_diffstat) {
                struct diff_options opts;
-               diff_setup(&opts);
+               repo_diff_setup(the_repository, &opts);
                opts.stat_width = -1; /* use full terminal width */
                opts.stat_graph_width = -1; /* respect statGraphWidth config */
                opts.output_format |=
@@ -728,8 +730,9 @@ static int try_merge_strategy(const char *strategy, struct commit_list *common,
                        die(_("unable to write %s"), get_index_file());
                return clean ? 0 : 1;
        } else {
-               return try_merge_command(strategy, xopts_nr, xopts,
-                                               common, head_arg, remoteheads);
+               return try_merge_command(the_repository,
+                                        strategy, xopts_nr, xopts,
+                                        common, head_arg, remoteheads);
        }
 }
 
@@ -898,7 +901,7 @@ static int suggest_conflicts(void)
        fputs(msgbuf.buf, fp);
        strbuf_release(&msgbuf);
        fclose(fp);
-       rerere(allow_rerere_auto);
+       repo_rerere(the_repository, allow_rerere_auto);
        printf(_("Automatic merge failed; "
                        "fix conflicts and then commit the result.\n"));
        return 1;
@@ -910,7 +913,7 @@ static int evaluate_result(void)
        struct rev_info rev;
 
        /* Check how many files differ. */
-       init_revisions(&rev, "");
+       repo_init_revisions(the_repository, &rev, "");
        setup_revisions(0, NULL, &rev, NULL);
        rev.diffopt.output_format |=
                DIFF_FORMAT_CALLBACK;
@@ -1189,7 +1192,7 @@ static int merging_a_throwaway_tag(struct commit *commit)
        tag_ref = xstrfmt("refs/tags/%s",
                          ((struct tag *)merge_remote_util(commit)->obj)->tag);
        if (!read_ref(tag_ref, &oid) &&
-           !oidcmp(&oid, &merge_remote_util(commit)->obj->oid))
+           oideq(&oid, &merge_remote_util(commit)->obj->oid))
                is_throwaway_tag = 0;
        else
                is_throwaway_tag = 1;
@@ -1334,6 +1337,10 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        die(_("%s - not something we can merge"), argv[0]);
                if (remoteheads->next)
                        die(_("Can merge only exactly one commit into empty head"));
+
+               if (verify_signatures)
+                       verify_merge_signature(remoteheads->item, verbosity);
+
                remote_head_oid = &remoteheads->item->object.oid;
                read_empty(remote_head_oid, 0);
                update_ref("initial pull", "HEAD", remote_head_oid, NULL, 0,
@@ -1424,7 +1431,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                goto done;
        } else if (fast_forward != FF_NO && !remoteheads->next &&
                        !common->next &&
-                       !oidcmp(&common->item->object.oid, &head_commit->object.oid)) {
+                       oideq(&common->item->object.oid, &head_commit->object.oid)) {
                /* Again the most common case of merging one remote. */
                struct strbuf msg = STRBUF_INIT;
                struct commit *commit;
@@ -1446,7 +1453,8 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                        goto done;
                }
 
-               if (checkout_fast_forward(&head_commit->object.oid,
+               if (checkout_fast_forward(the_repository,
+                                         &head_commit->object.oid,
                                          &commit->object.oid,
                                          overwrite_ignore)) {
                        ret = 1;
@@ -1497,7 +1505,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                         * HEAD^^" would be missed.
                         */
                        common_one = get_merge_bases(head_commit, j->item);
-                       if (oidcmp(&common_one->item->object.oid, &j->item->object.oid)) {
+                       if (!oideq(&common_one->item->object.oid, &j->item->object.oid)) {
                                up_to_date = 0;
                                break;
                        }