Merge branch 'js/rebase-autostash-detach-fix'
[gitweb.git] / builtin / merge.c
index e331ca6d481005f6122fa6fda6075728f893632d..c3c976d471ce78268e673a5135a4c37ebc6d0f6d 100644 (file)
@@ -224,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;
 }
@@ -390,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;
 
@@ -453,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 |=
@@ -729,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);
        }
 }
 
@@ -899,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;
@@ -911,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;
@@ -1335,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,
@@ -1356,31 +1362,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
 
        if (verify_signatures) {
                for (p = remoteheads; p; p = p->next) {
-                       struct commit *commit = p->item;
-                       char hex[GIT_MAX_HEXSZ + 1];
-                       struct signature_check signature_check;
-                       memset(&signature_check, 0, sizeof(signature_check));
-
-                       check_commit_signature(commit, &signature_check);
-
-                       find_unique_abbrev_r(hex, &commit->object.oid, DEFAULT_ABBREV);
-                       switch (signature_check.result) {
-                       case 'G':
-                               break;
-                       case 'U':
-                               die(_("Commit %s has an untrusted GPG signature, "
-                                     "allegedly by %s."), hex, signature_check.signer);
-                       case 'B':
-                               die(_("Commit %s has a bad GPG signature "
-                                     "allegedly by %s."), hex, signature_check.signer);
-                       default: /* 'N' */
-                               die(_("Commit %s does not have a GPG signature."), hex);
-                       }
-                       if (verbosity >= 0 && signature_check.result == 'G')
-                               printf(_("Commit %s has a good GPG signature by %s\n"),
-                                      hex, signature_check.signer);
-
-                       signature_check_clear(&signature_check);
+                       verify_merge_signature(p->item, verbosity);
                }
        }
 
@@ -1471,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;